Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript validation form is not working
    text
    copied!<p>I created a html SignUp page with validation in javascript. Here is the validation code.</p> <h1>SignUp.html</h1> <p>&lt;<em>script type="text/javascript"</em>></p> <pre><code>function validateForm() { var id = document.signup.LoginId; var password = document.signup.LoginPassword; var cpassword = document.signup.ConfirmPassword; var city = document.signup.City; var state = document.signup.State; var number = document.signup.PhoneNumber; var email = document.signup.Email; var address = document.signup.Address; var zipcode = document.signup.ZipCode; if(id.value == "") { window.alert("Error: Username should be filled out."); id.focus(); return false; } re = /^\w+$/; if(!re.test(id.value)) { window.alert ("Error: Username must contain only letters, numbers and underscores."); id.focus(); return false; } if(id.length &lt; 6) { window.alert("Error: Username must contain at least 6 charecters."); id.focus(); return false; } if(id.length &gt; 12) { window.alert("Error: Username must not be greater than 12 charecters."); id.focus(); return false; } if(password.value != "" &amp;&amp; password.value == cpasswotd.value) { if(password.length &lt; 6) { window.alert("Error: Password must contain at least 6 charecters."); password.focus(); return false; } if(password.length &gt; 12) { window.alert("Error: Password must not be greater than 12 charecters."); password.focus(); return false; } if(password.value == id.value) { window.alert("Error: Password must be different from UserName."); password.focus(); return false; } re = /[0-9]/; if(!re.test(password.value)) { window.alert("Error: Password must contain at least one number."); password.focus(); return false; } re = /[a-z]/; if(!re.test(password.value)) { window.alert("Error: Password must contain at least one lowercase letter (a-z)."); password.focus(); return false; } re = /[A-Z]/; if(!re.test(password.value)) { window.alert("Error: Password must contain at least one uppercase letters (A-Z)."); password.focus(); return false; } }else { window.alert("Error: Please check that you've entered and Confirmed your Password."); password.focus(); return false; } window.alert("You have entered a valid password: "+password.value); return true; if(city.value == "") { window.alert("City must not be null."); city.focus(); return false; } if(state.value == "") { window.alert("State must not be null."); state.focus(); return false; } if(number.value == "") { window.alert("Phone number must not be null."); number.focus(); return false; } if(number.length != 10) { window.alert("Phone number must be 10 digits."); number.focus(); return false; } if (email.value == "") { window.alert("Please enter a valid e-mail address."); email.focus(); return false; } if (email.value.indexOf("@", 0) &lt; 0) { window.alert("Please enter a valid e-mail address."); email.focus(); return false; } if (email.value.indexOf(".", 0) &lt; 0) { window.alert("Please enter a valid e-mail address."); email.focus(); return false; } re = /^\w+$/ if(!re.test(address.value)) { window.alert("Error: Address must contain only letters, numbers and underscores."); address.focus(); return false; } if(zipcode.value == "") { window.alert("Error: Zipcode must not be null."); zipcode.focus(); return false; } if(zipcode.length &gt; 6) { window.alert("Error: zipcode must not less than 6 digits."); zipcode.focus(); return false; } </code></pre> <p>} &lt;<em>/script</em>></p> <p>The validation form is not working properly. When i don't give the username, then it is showing an error window. If i don't give the password and don't confirm password then also it is giving error window, and if i just give any username and password and confirm password fields, (password and confirm password fileds are not same.) then it is not showing any error pages. It is showing http status 500 error.</p> <p>Here is my error log details.</p> <pre><code>Sep 22, 2013 4:59:47 PM org.apache.catalina.core.AprLifecycleListener init INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: .:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java Sep 22, 2013 4:59:47 PM org.apache.tomcat.util.digester.SetPropertiesRule begin WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:WebsiteProj' did not find a matching property. Sep 22, 2013 4:59:47 PM org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler ["http-bio-8080"] Sep 22, 2013 4:59:47 PM org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler ["ajp-bio-8009"] Sep 22, 2013 4:59:47 PM org.apache.catalina.startup.Catalina load INFO: Initialization processed in 1532 ms Sep 22, 2013 4:59:47 PM org.apache.catalina.core.StandardService startInternal INFO: Starting service Catalina Sep 22, 2013 4:59:47 PM org.apache.catalina.core.StandardEngine startInternal INFO: Starting Servlet Engine: Apache Tomcat/7.0.37 Sep 22, 2013 4:59:49 PM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["http-bio-8080"] Sep 22, 2013 4:59:49 PM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["ajp-bio-8009"] Sep 22, 2013 4:59:49 PM org.apache.catalina.startup.Catalina start INFO: Server startup in 1506 ms Sep 22, 2013 5:00:07 PM org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet [SignUpServlet] in context with path [/WebsiteProj] threw exception java.lang.NumberFormatException: For input string: "" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48) at java.lang.Integer.parseInt(Integer.java:470) at java.lang.Integer.parseInt(Integer.java:499) at com.dao.SignUpServlet.doPost(SignUpServlet.java:50) at javax.servlet.http.HttpServlet.service(HttpServlet.java:647) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) at java.lang.Thread.run(Thread.java:680) </code></pre> <p>Can anybody help me to fix this.</p> <p>Thank You.</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