Friday, 10 February 2017

how to check string and number in jquery

var EmailCheck = new RegExp(/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/);

var UsernameVal = document.getElementById('mobileNo').value;

if (!isNaN(parseFloat(UsernameVal)) && isFinite(UsernameVal)) {
    if (UsernameVal.length < 10 || UsernameVal.length > 10 || UsernameVal.length > 11) {
        document.getElementById("errorMsg").innerHTML = "Please Enter 10 Digit Mobile No. ";
        return false;
    }
} else if (!EmailCheck.test(UsernameVal)) {
    document.getElementById("errorMsg").innerHTML = "Please Enter Correct Email";
    return false;
}

No comments:

Post a Comment