.

Saturday, December 21, 2013

Validation

validateFormOnSubmit ( ) This is a master(prenominal) habit that calls a series of sub percentages, severally of which checks a single form grammatical constituent for compliance. If the element complies than sufunction returns an change string. otherwise it returns a message describing the flaw and highlight earmark element with yellow. function validateFormOnSubmit(theForm) { volt-ampere  lawsuit = ;   antecedent += validateUsername(theForm.username);   reason += validatePassword(theForm.pwd);   reason += validateEmail(theForm.email);   reason += validatePhone(theForm.phone);   reason += validateEmpty(theForm.from);          if (reason != ) {     alert(Some fields emergency discipline: + reason);     return false;   }   return lawful; } validateEmpty ( ) The function at a lower place checks if a required field has been unexpended empty. If the required field is blank, we return the misapprehension string to the main function. If its non b lank, the function returns an empty string. function validateEmpty(fld) {     var geological fault = ;        if (fld.value. distance == 0) {         fld.style.background = Yellow;          error = The required field has non been fill up in.     } else {         fld.style.
Ordercustompaper.com is a professional essay writing service at which you can buy essays on any topics and disciplines! All custom essays are written by professional writers!
background = White;     }     return error;    } Back to top validateUsername ( ) The function below checks if the user entered anything at all in the username field. If its not blank, we check the length of the string and permit simply usernames that ar between 5 and 15 characters. Next, we use the Ja vaScript regular construction /\W/ to rule ! out illegal characters from appearing in usernames. We loss to allow only letters, numbers and underscopes. function validateUsername(fld) {     var error = ;     var illegalChars = /\W/; // allow letters, numbers, and underscores       if (fld.value == ) {         fld.style.background = Yellow;          error = You didnt enter a username.;     } else if ((fld.value.length < 5) || (fld.value.length > 15)) {         fld.style.background = Yellow;          error = The username is...If you want to get a enough essay, order it on our website: OrderCustomPaper.com

If you want to get a full essay, visit our page: write my paper

No comments:

Post a Comment