Click here to Skip to main content
13,006,530 members (63,076 online)
Rate this:
Please Sign up or sign in to vote.
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:
var addresspat=/^(@"[^\d\/]")$/;
          var address=document.getElementById("<%=txtAddr.ClientID%>").value;
         var matchArray =  address.match(addresspat);
         if (matchArray == null)
              alert("Enter The Correct Address");
              return false;
Posted 26-Mar-13 15:14pm
Updated 26-Mar-13 15:43pm
ThePhantomUpvoter 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

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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
var PAT_CHECK = /(\d+\/\d+).*/g
var ret = val.match(PAT_CHECK);
if (ret == null)
    alert("Invalid address!");


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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170628.1 | Last Updated 28 Mar 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100