Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to validate in javascript to accept numbers and alphabets but should not accept only numbers and special character "/" example:it can be of "12/90,annanagar" but it should not be as "12/" or "12"..can anyone help me to do this in javascript


code i tried:
C#
var addresspat=/^(@"[^\d\/]")$/;
          var address=document.getElementById("<%=txtAddr.ClientID%>").value;
         var matchArray =  address.match(addresspat);
         if (matchArray == null)
   {
   }
   else{
              alert("Enter The Correct Address");
              document.getElementById("<%=txtAddr.ClientID%>").focus();
              return false;
   }
Posted
Updated 26-Mar-13 15:43pm
v2
Comments
[no name] 26-Mar-13 21:30pm    
Sure. Post the code that you have tried and describe the problem with your code.
Surendra0x2 26-Mar-13 22:47pm    
Check Regex like [a-zA-Z0-9] with Custom Validator

1 solution

Hello Nityasri,

Is it very much essentials that your address must start with numbers followed by a slash then numbers? If so then try with
JavaScript
var PAT_CHECK = /(\d+\/\d+).*/g
var ret = val.match(PAT_CHECK);
if (ret == null)
    alert("Invalid address!");


Regards,
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900