By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,516 Members | 1,137 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,516 IT Pros & Developers. It's quick & easy.

How to write RegExp digits only, starting character >= 1?

P: 27
I have a form where I would like to perform some validation using a javascript function. I cant' figure out the RegExp.

Expand|Select|Wrap|Line Numbers
  1. function is_number(target) {
  2.    target.value = trim(target.value);
  3.    var filter = RegExp("^[help]");
  4.    if(filter.test(target.value))
  5.       return true;
  6.    target.style.background = "#ffcccc";
  7.    return false;
  8. }
  9.  

criteria:
The first character must be greater than 1, the user can only enter in digits, and must be less than 100.

Thanks.
Nov 21 '07 #1
Share this Question
Share on Google+
1 Reply


gits
Expert Mod 5K+
P: 5,390
hi ...

try the following:

Expand|Select|Wrap|Line Numbers
  1. /^[1-9]{1}\d{0,1}$/
kind regards
Nov 22 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.