2013-12-09

Practice Final Question 1.

Originally Posted By: Sean Vail
Sindhu Pothireddy
Bisma Janjua
Yubo Wang
Bao Nguyen
Sean Vail

When the form submits, it's designated action is to run the javascript function validateMe(). If all the inputs are not equal to "" then the function will return true and the data will be sent to the server.

Code:


   Test page


    
    Field 1:
 
    Field 2:
 
     


   function validateMe() 

    if (document.form1.field1.value == "") 
    { 
        alert("Please complete Field 1"); 
        return false; 
    } 
     
    if (document.form1.field2.value == "") 
    { 
        alert("Please complete Field 2"); 
        return false; 
    } 
     
    return true; 





'''Originally Posted By: Sean Vail''' Sindhu Pothireddy<br>Bisma Janjua<br>Yubo Wang<br>Bao Nguyen<br>Sean Vail<br><br>When the form submits, it's designated action is to run the javascript function validateMe(). If all the inputs are not equal to &quot;&quot; then the function will return true and the data will be sent to the server.<br><br>Code: <br><br><br>&nbsp; &nbsp;Test page<br><br><br>&nbsp; &nbsp;&nbsp; <br>&nbsp; &nbsp; Field 1: <br>&nbsp; <br>&nbsp; &nbsp; Field 2: <br>&nbsp; <br>&nbsp; &nbsp; &nbsp; <br> <br><br>&nbsp; &nbsp;function validateMe()&nbsp; <br>{&nbsp; <br>&nbsp; &nbsp; if (document.form1.field1.value == &quot;&quot;)&nbsp; <br>&nbsp; &nbsp; {&nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; alert(&quot;Please complete Field 1&quot;);&nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; return false;&nbsp; <br>&nbsp; &nbsp; }&nbsp; <br>&nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; if (document.form1.field2.value == &quot;&quot;)&nbsp; <br>&nbsp; &nbsp; {&nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; alert(&quot;Please complete Field 2&quot;);&nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; return false;&nbsp; <br>&nbsp; &nbsp; }&nbsp; <br>&nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; return true;&nbsp; <br>}&nbsp; <br><br><br><br><br>
X