You must Sign In to post a response.
  • Category: JavaScript

    Need javascript for mobile and email validation on tab key press

    want java script for email and mobile validation.

    we are developing asp.net web application

    1)when we enter no less than 10 digit( eg.98023) in textbox and press tab key it should show incorrect mobile number and it will not allow alphabates or special character and 10 digit no.

    2)when we enter sr@g in textbox and press tab key it should show incorrect email id .

    Thanks in advance.
  • #755752
    Check this code to validate email using JQuery



    $(document).ready(function() {

    $('#btn-submit').click(function() {

    $(".error").hide();
    var hasError = false;
    var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;

    var emailaddressVal = $("#UserEmail").val();
    if(emailaddressVal == '') {
    $("#UserEmail").after('<span class="error">Enter email address.</span>');
    hasError = true;
    }

    else if(!emailReg.test(emailaddressVal)) {
    $("#UserEmail").after('<span class="error">Enter a valid email address.</span>');
    hasError = true;
    }

    if(hasError == true) { return false; }

    });
    });

    Thanks & Regards
    Anil Kumar Pandey
    Microsoft MVP, DNS MVM


  • Sign In to post your comments