Note that there are some explanatory texts on larger screens.

plurals
  1. POI am having problems getting my form to validate or submit
    primarykey
    data
    text
    <p>My form does not seem to be validating or submitting. It was submitting and validating before, but the Jquery error messages were not all displaying at the same time so I had to edit the code, and now it is not submitting or validating at all.</p> <p>Here is my JS:</p> <pre><code>function validateUserName(user) { var u = document.forms["NewUser"]["user"].value var uLength = u.length; var illegalChars = /\W/; // allow letters, numbers, and underscores if (u == null || u == "") { return "You Left the Username field Emptyyy"; } else if (uLength &lt;4 || uLength &gt; 11) { return "The Username must be between 4 and 11 characters"; } else if (illegalChars.test(u)) { return "The Username contains illegal charectors men!"; } else { return ""; } } function validatePassword(pwd) { var p = document.forms["NewUser"]["pwd"].value var cP = document.forms["NewUser"]["confirmPwd"].value var pLength = p.length; if (p == null || p == "") { return "You left the password field empty"; } else if (pLength &lt; 6 || pLength &gt; 20) { return "Your password must be between 6 and 20 characters in length"; } else if (p != cP) { return "The passwords do not match!" } else { return ""; } } function validateEmail(email) { var e = document.forms["NewUser"]["email"].value var eLength = e.length; var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ; var illegalChars= /[\(\)\&lt;\&gt;\,\;\:\\\"\[\]]/ ; if (eLength == "" || eLength == null) { return "You left the email field blank!"; } else if (e.match(illegalChars)) { return "ILEGAL CHARECTORS DETECTED EXTERMINATE"; } else { return ""; } } function validateFirstName(fname) { var f = document.forms["NewUser"]["fName"].value; var fLength = f.length; var illegalChars = /\W/; if(fLength &gt; 20) { return "First Name has a max of 20 characters"; } else if (illegalChars.test(f)) { return "Numbers,letter and underscores in first name only"; } else { return ""; } } function validateLastName(lName) { var l = document.forms["NewUser"]["lName"].value; var lLength = l.length; var illegalChars = /\W/; if(lLength &gt; 100) { return "Last Name has a max of 100 characters"; } else if (illegalChars.test(f)) { $("#ErrorLname").text("Numbers,letter and underscores in last name only"; } else { return ""; } } function validateForm() { /* valid = true; //call username function valid = valid &amp;&amp; validateUserName(); //call password function valid = valid &amp;&amp; validatePassword(); //call email function valid = valid &amp;&amp; validateEmail(); //call first name function valid = valid &amp;&amp; validateFirstName(); //call first name function valid = valid &amp;&amp; validateLastName(); return valid; */ var error = ""; //call username function error += "\n"+validateUserName(); //call password function error += "\n"+validatePassword(); error += "\n"+validateEmail(); error += "\n" + validateFirstName(); error += "\n" + validateLastName(); if(error === ""){ return true; } else{ $("#ErrorUser").text(error); $("#ErrorEmail").text(error); $("#ErrorFname").text(error); $("#ErrorPassword1").text(error); $("#ErrorLname").text(error); return false; } } $('#your-form').submit(validateForm); </code></pre> <p>Fiddle: <a href="http://jsfiddle.net/cyKgD/" rel="nofollow">http://jsfiddle.net/cyKgD/</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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