Note that there are some explanatory texts on larger screens.

plurals
  1. POonsubmit is failing to javascript function
    text
    copied!<p>In below code, there is a form to create login for new user. And on the press of continue button it should call 'validateForm()' function. Where it is checking the values filled in form and on missing of proper value(s) it should give the alert message. But, is not giving any alert even on error, like I am pressing 'continue' even the form is completely empty. </p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;&lt;/title&gt; &lt;script type="text/javascript"&gt; function validateForm() { var email=document.forms["newlogin"]["email"].value; var cemail=document.forms["newlogin"]["cemail"].value; var pass=document.forms["newlogin"]["pwd"].value; var cpass=document.forms["newlogin"]["cpwd"].value; var answ1=document.forms["newlogin"]["ans1"].value; var answ2=document.forms["newlogin"]["ans2].value; alert("I am IN"); if(email==null || email=="" || cemail==null || cemail=="") { alert("Enter Email ID and confirm."); return false; } if(pass==null || pass=="" || cpass==null || cemail=="") { alert("Enter Password and confirm."); return false; } if(answ1==null || answ1=="" || answ2=null || answ2=="") { alert("Enter Answer 1 &amp; Answer 2."); return false; } if(email!=cemail) { alert("Confirmed Email ID is not matching."); return false; } if(pass!=cpass) { alert("Confirmed Password is not matching."); return false; } } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;h1 style="font:swis721 bt"&gt;enginenc&lt;/h1&gt; &lt;form name="newlogin" method="POST" action="http://localhost/cgi-bin/createlogin" onsubmit="return validateForm()"&gt; &lt;table align="center" cellpadding="10" cellspacing="0" style="margin-top:2cm;background-color:#FFD700;border-top:1px solid;border-bottom:1px solid;border-left:1px dotted;border-right:1px dotted" border=0&gt; &lt;tr&gt; &lt;td align="left" style="font:westwood let"&gt;Enter a valid Email ID:&lt;/td&gt; &lt;td align="left" style="font:westwood let"&gt;&lt;input type="text" name="email"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="left" style="font:westwood let"&gt;Confirm the Email ID:&lt;/td&gt; &lt;td align="left" style="font:westwood let"&gt;&lt;input type="text" name="cemail"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="left" style="font:westwood let"&gt;Enter password:&lt;/td&gt; &lt;td align="left" style="font:westwood let"&gt;&lt;input type="password" name="pwd"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="left" style="font:westwood let"&gt;Confirm Passowrd:&lt;/td&gt; &lt;td align="left" style="font:westwood let"&gt;&lt;input type="password" name="cpwd"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="left" style="font:westwood let"&gt;Select Question 1:&lt;/td&gt; &lt;td align="left" style="font:westwood let"&gt;&lt;select name="ques1"&gt;&lt;option value=1&gt;1. What is your mother's maiden name?&lt;/option&gt;&lt;option value=2&gt;2. Which is your birth city?&lt;/option&gt;&lt;option value=3&gt;3. Which is your favorite place?&lt;/option&gt;&lt;/select&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="left" style="font:westwood let"&gt;Answer 1:&lt;/td&gt; &lt;td align="left" style="font:westwood let"&gt;&lt;input type="text" name="ans1"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="left" style="font:westwood let"&gt;Select Question 2:&lt;/td&gt; &lt;td align="left" style="font:westwood let"&gt;&lt;select name="ques2"&gt;&lt;option value=1&gt;1. Which is your dream car?&lt;/option&gt;&lt;option value=2&gt;2. What is your nick name?&lt;/option&gt;&lt;option value=3&gt;3. Who is your favorite singer?&lt;/option&gt;&lt;/select&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="left" style="font:westwood let"&gt;Answer 2:&lt;/td&gt; &lt;td align="left" style="font:westwood let"&gt;&lt;input type="text" name="ans2"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="left" style="font:westwood let"&gt;&lt;input style="margin-left:3cm;padding:11px" type="submit" value="Continue"&gt;&lt;/td&gt; &lt;td align="left" style="font:westwood let"&gt;&lt;input style="padding:11px" type="reset"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Here, on submit of the form using <strong>onsubmit()="return validateForm()"</strong> function. Form is not calling the function <strong>validateForm()</strong>. I tried alot but did not find the error. Please help. Thanks.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload