dojo - ValidationTextBox - "regular expression syntax"

I have to create textboxes in dojo/javascript.

It should validate values. So i am planning to use "dijit/form/ValidationTextBox"

In textbox1(i.e. validationtextbox) , i have to check value should be 1 or 0 and no other values. What should be the  "regular expression syntax"  for it....


In textbox2(i.e. validationtextbox) , i have to check value should be a number. What should be the  "regular expression syntax"  for it....

In textbox3(i.e. validationtextbox) , i have to check length of string should not be more than 200 characters. What should be the  "regular expression syntax"  for it....

pl guide

thanks a lot
ts84zsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Terry WoodsIT GuruCommented:
I haven't used that tool, but here's some regular expressions that should work:

0 or 1:
/^[01]$/
Number (unsigned integer):
/^\d+$/
Number (optionally signed integer):
/^[-+]?\d+$/
Number (optionally signed decimal, optional decimal places):
/^[-+]?\d+(\.\d+)$/
Length <= 200:
/^.{,200}$/
0
Terry WoodsIT GuruCommented:
Looking at this example, you would just need to remove the / characters from my patterns above, something like this:
     <input type="text"
            dojoType="dijit.form.ValidationTextBox"
            regExp="^[-+]?\d+(\.\d+)$"
            required="true"
            invalidMessage="You must enter a number">

Open in new window

0
ts84zsAuthor Commented:
yes on dojo's website its mentioned that "Validationbox regular expression syntax" is exactly similar to "Javascript regular expression syntax"  

So whatever is in javascript, pl guide me... thanks a lot...
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

ts84zsAuthor Commented:
thanks a lot i am looking into your comments
0
ts84zsAuthor Commented:
those are not working ... pl guide
0
Terry WoodsIT GuruCommented:
Start with a simple pattern like:
            regExp="^a$"
which should only match when only an "a" character has been entered, or even:
            regExp="a"
which should match when there's an "a" character within a string.

See if you can get that working, and go from there.
0
ts84zsAuthor Commented:
regExp:'[A-Z,a-z,0-9,_, ,-]{1,254}
works to put in text which can have characters from A-Z, a-z, 0-9, a space, _ , - and which has maximum of 254 characters

How do i put validation for not null... pl guide thanks a lot
0
Terry WoodsIT GuruCommented:
Using the same syntax as your example:
 regExp:'.'
although that also allows a value that is only a whitespace character such as a space. To require a non-whitespace character:
 regExp:'\S'
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.