ejwswtmbbv
New Member
I can't figure out why this is not working as i did everything correct.This is a simple create a account form. I put validation code for some of the field like name, email and password. There are many other fields. but first i m trying this.The like is here:\[code\]jsfiddle\[/code\]and the code of HTML: First Name\[code\] <input type="text" name="fname" id="fname"/> <input type="text" name="lname" id="lname /> <input type="text" name="remail" id="remail" /> New Pasword <input type="password" name="rpass" id="rpass" /> <input name="regis" type="submit" class="color2" id="id" value="http://stackoverflow.com/questions/15801989/Submit" />\[/code\]The javascript code here:\[code\] function validateRegis() {//regex for fname and lnamevar fname = $("#fname").val();var lname = $("#lname").val(); var patt_n = /[a-z]{2,20}/i;//checking fname and lname for regex matching var ftest = patt_n.test(fname);var ltest = patt_n.test(lname);var remail = $("#remail").val();var filter = /^[a-zA-Z0-9]+[a-zA-Z0-9\_\.\-]+[a-zA-Z0-9\_\-]+@[a-zA-Z0-9]+[a-zA-Z0-9\.\-]+[a-zA-Z0-9]+\.[a-z]{2,4}$/;var test = filter.test(remail);var rpass = $("#rpass").val();var patt = /[a-z0-9~!@#$%^&*()_\ ]/i;var test2 = patt.test(rpass);if (fname === "" || ftest === false) { alert("Please provide first name!"); $("#fname").focus(); return false;} else if (lname === "" || ltest === false) { alert("Please provide Last name!"); $("#lname").focus(); return false;} else if (remail === "" || test === false) { // alert("Please provide email in correct format!"); $("#remail").focus(); return false;} else if (rpass === "" || rpass.length < 8 || test2 === false) { alert("Please provide password!"); $("#rpass").focus(); return false;} else if ((fname !== "") & (lname !== "") & (remail !== "") & (test === true) & (rpass >= 8) & test2 === true) { return true;}}\[/code\]It needs jquery to run the code.