robert_gsfame Posted April 26, 2010 Share Posted April 26, 2010 I wish to validate textbox so that anything besides numeric is not allowed I try to use isNan but not working (don't know why) then i try to use match() here is the code var test = /[0-9]+$/; if(!(mystring.match(test)) alert("wrong");} when i type "1234abc" alert appear but when i type "abc1234" alert not appear which part should be modified? thx in advance Link to comment https://forums.phpfreaks.com/topic/199753-match-small-problem/ Share on other sites More sharing options...
robert_gsfame Posted April 26, 2010 Author Share Posted April 26, 2010 oops i miss the first part /\b[0-9]+$/; Link to comment https://forums.phpfreaks.com/topic/199753-match-small-problem/#findComment-1048445 Share on other sites More sharing options...
salathe Posted April 26, 2010 Share Posted April 26, 2010 You're probably really wanting to use an anchor to make sure that all characters in the string are digits rather than just those at the end. Another alternative would be to test if any one character is not a digit. Link to comment https://forums.phpfreaks.com/topic/199753-match-small-problem/#findComment-1048489 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.