<%--This is my form i have done form validation using jquery but one problem is all fields are filled and after that
first,second...(any),and third field are delete (empty textbox) and this form submited without validate why please help
me this case--%>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs"
Inherits="WebApplication4.WebForm2" %>
label.error {
color: red;
display: block;
margin-left: 40px;
}
$(document).ready(function() {
$.validator.addMethod("match", function(value, element)
{
return this.optional(element) || /^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\.[a-zA-Z.]{2,5}$/i.test(value);
}, "Please enter a valid email address.");
//custom validation rule for Dropdown List
$.validator.addMethod("CheckDropDownList", function (value, element, param) {
if (value == '0')
return false;
else
return true;
},"Please select a Department.");
$("#form1").validate({
rules: {
//
<%=name.UniqueID %>:{
required:true,
minlength: 10,
},
<%=email.UniqueID %>: {
required: true,
//email:true,
match:true,
},
<%=field.UniqueID %>: {
required: true,
digits:true,
},
<%=ddlDept.UniqueID %>:{
CheckDropDownList:true,
},
<%=txtMobNo.UniqueID %>: {
required: true,
digits:true,
minlength: 10,
pattern: [/^[7-9]{1}[0-9]{9}$/],
},
},
messages: {
<%=name.UniqueID %>:{
required: " Required Field *",
minlength: "Minimum length 10 digit",
},
<%=email.UniqueID %>: {
required: "Email id is required",
//email: "This is not correct Email Id",
},
<%=txtMobNo.UniqueID %>: {
required: "Enter Mob No",
minlength: "Mobile No should be 10 digit",
},
},
});
});
First Name
E-Mail ID
Mobile Number
Department
2 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
AjeeshPosted Jan 1, 2018, 2:55 PM
AjeeshPosted Jan 1, 2018, 2:53 PM