The code will be helpful in validating data entry forms such as: user registration, user creation. validate_required is used by all other functions
function validate_required(field,alerttxt) { with (field) { if (value==null||value=='') { alert(alerttxt);return false } else {return true} } } function validateTicketCreateForm(thisform) { with (thisform) { if (validate_required(type,'Type must be filled out!')==false) {type.focus();return false} if (validate_required(subject,'Subject must be filled out!')==false) {subject.focus();return false} } } function validate_customer_create_form(thisform) { with (thisform) { if (validate_required(firstName,'First name must be filled out!')==false) {firstName.focus();return false} if (validate_required(lastName,'Last name must be filled out!')==false) {lastName.focus();return false} if (validate_required(phone,'Phone must be filled out!')==false) {phone.focus();return false} } } function validateUserCreateForm(thisform) { with (thisform) { if (validate_required(firstName,'First name must be filled out!')==false) {firstName.focus();return false} if (validate_required(lastName,'Last name must be filled out!')==false) {lastName.focus();return false} if (validate_required(shortName,'Short name must be filled out!')==false) {shortName.focus();return false} if (validate_required(username,'Username must be filled out!')==false) {username.focus();return false} if (validate_required(password,'Password must be filled out!')==false) {password.focus();return false} if (password.value.length < passwordLength.value) {alert("Password must be at least " + passwordLength.value +" char long"); password.focus();return false} if (validate_required(password2,'Please re-enter password!')==false) {password2.focus();return false} if (password.value != password2.value) { alert("Password did not match"); password2.focus(); return false } } }
From: http://sitestree.com/?p=4778
Categories:13
Tags:
Post Data:2012-10-22 22:13:07
Shop Online: <a href='https://www.ShopForSoul.com/' target='new' rel="noopener">https://www.ShopForSoul.com/</a>
(Big Data, Cloud, Security, Machine Learning): Courses: <a href='http://Training.SitesTree.com' target='new' rel="noopener"> http://Training.SitesTree.com</a>
In Bengali: <a href='http://Bangla.SaLearningSchool.com' target='new' rel="noopener">http://Bangla.SaLearningSchool.com</a>
<a href='http://SitesTree.com' target='new' rel="noopener">http://SitesTree.com</a>
8112223 Canada Inc./JustEtc: <a href='http://JustEtc.net' target='new' rel="noopener">http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning) </a>
Shop Online: <a href='https://www.ShopForSoul.com'> https://www.ShopForSoul.com/</a>
Medium: <a href='https://medium.com/@SayedAhmedCanada' target='new' rel="noopener"> https://medium.com/@SayedAhmedCanada </a>