complete form validation using javascript-php -



complete form validation using javascript-php -

i trying validate password using regex , function. in same form have few other fields(viz. name,email,password,confirm password,username,mobile no, street, city, country(select tag), gender(radio button). questions or rather confusions are:

do need check if field empty(on both client side , server side) in spite of using 'required' attribute?

i have created new function each of field trying validate(just passcheck() makes code unnecessarily lengthy. here re-usability of code not done. in other way can implement validation accomplish it. bit boring implement similar kind of logic or methods 1 time again , 1 time again minor changes.

javascript variable can not have same name of function name contains variable.? why? because when trying utilize same name,code didn't worked. when checked same code on jsfiddle.net showed me error variable.

whats purpose of using php functions mysql_real_escape_string() non text fields(select box , radio button). here not allowing user come in else defined options only.

is practice maintain 1 radio button checked gender.?

i storing gender in database char(1) stores first character of male/female. how store same using enum.?

here code :

javascript:

function passcheck() { var passexp = /^(?=.*\d)(?=.*[a-z])(?=.*[a-z])[0-9a-za-z]{8,}$/; var passwordelement = document.getelementbyid("password"); var passwordvalue = passwordelement.value; if (passwordvalue.trim() !== "") { if (!passwordvalue.match(passexp)) { passwordelement.focus(); document.getelementbyid('error2').innerhtml = "password should atleast 8 character long , must contain @ to the lowest degree 1 digit,at to the lowest degree 1 lower case,at to the lowest degree 1 upper case."; homecoming false; } else { document.getelementbyid('error2').innerhtml = ""; homecoming true; } } else { passwordelement.focus(); document.getelementbyid('error2').innerhtml = "password can't blank"; homecoming true; } }

html:

<label for="password">* password </label> <input type="password" name="password" placeholder="password should atleast 8 characters" id="password" size="40" required="required" onblur="passcheck()"/> <span id="error2"></span>

javascript php html

Comments

Popular posts from this blog

php - Edges appear in image after resizing -

ios8 - iOS custom keyboard - preserve state between appearances -

Delphi change the assembly code of a running process -