Client side Validation control in asp.net .

We can write the client side validation control in jquery-

Required Field Validator

You can use it to make sure that the user has entered something in a TextBox control.


if ($("#txtName").val() == ''") {             
             $("#ctrlMsg").html("<span>Please enter Name!</span>");              
             return false;
            }

Mobile No Validation Control

     var str = $("#txtMobile").val();
            var filter = /^[1-9]d{9}$/;
            if (!filter.test(str)) {          
            $("#ctrlMsg").html("<span>Please enter a valid mobile number!</span>");          
            return;
            }

Email Validation Control

   var str = $("#txtEmail").val();
            var filter = /^([w-]+(?:.[w-]+)*)@((?:[w-]+.)*w[w-]{0,66}).([a-z]{2,6}(?:.[a-z]{2})?)$/i;
            if (!filter.test(str)) {
            $("#ctrlMsg").html("<span>Please enter a valid email!</span>");
            return false;
            }

Html code

<input type="text" id="txtName"  placeholder="Name"  />
 <input type="text" id="txtEmail" placeholder="Email"  />
 <input type="text" id="txtMobile"   maxlength="10" placeholder="Mobile No"  />
 <div  id="ctrlMsg"></div>

Need Help? Contact Us.

Log in

*
*

Forgot password?

*

New User

*
*
*
*