Saturday, 20 October 2012

alpha Numeric validation in javascript


// check the user id
 function IsalphaNumericValidate(e)
 {
       var key;  
        if (e.keyCode)
          key = e.keyCode;
        else if (e.which)
          key = e.which;
         
          if (/[^A-Za-z0-9.]/.test(String.fromCharCode(key)))
          {          //fails test
            alert("invalid");
                         document.getElementById("<%=txtUserName.ClientID %>").focus();
                           return false;
          }
                     
                        return true;
                       
                }


================================

onkeypress="Javascript:return IsalphaNumericValidate(event)"

No comments:

Post a Comment