Skip to main content

Posts

How to validate asp.net form using Jquery

In this post I will show you how to validate asp.net form using jqery. Create a new website,add a new js file ,and add following code inside it function validateForm(e) { var formIsValid = true; // check that a valid email address has been entered var emailRegExp = /[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}/; if (!emailRegExp.test(String($("#txtEmail").val()).toUpperCase())) { addError("txtEmail", "Please enter a valid email address."); formIsValid = false; } else { removeError("txtEmail"); } // check that first name has one or more characters if ($("#txtFirstName").val() == '') { addError("txtFirstName", "This field is required."); formIsValid = false; } else { removeError("txtFirstName"); } // check that last name has one or more characters if ($("#txtLastName").val() == '') { …