aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes validation for numbers and alphabets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "validation for numbers and alphabets" Watch "validation for numbers and alphabets" New topic
Author

validation for numbers and alphabets

bharani rao
Ranch Hand

Joined: Apr 06, 2009
Posts: 164
hi,

i'm trying to validate only numbers in one input text and to validate only alphabets for another text.

here is the code



i'm getting the input in a text box.
i'm declaring var alpha = /[a-zA-z]/; to specify the a-zA-Z
i might be declaring something like var numb=/0-9/; for numbers.

some text box should get only text and some should get only numbers.
to get only numbers i tried,




stud is the name of my form.
when i run it shows NaN in the output text boxes which should show sum and average and not the alert box.

any help please.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Well I do not see how you are using alpha

Your regexp would also fail if you were to enter A1 into the textbox.

Eric
bharani rao
Ranch Hand

Joined: Apr 06, 2009
Posts: 164
hi eric,

yes, it would fail me...
is this expression ok

to check both alpha numerals.

or is there a fundamental mistake i'm making???


thanks in advance
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Would still fail



Without giving you the exact answer in code, you are NOT testing the ENTIRE string. You need some +$^ characters in there.

Eric
bharani rao
Ranch Hand

Joined: Apr 06, 2009
Posts: 164
thank you eric
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
So what did you come up with?

Eric
bharani rao
Ranch Hand

Joined: Apr 06, 2009
Posts: 164
hi eric,
not yet..
i have to do it.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: validation for numbers and alphabets
 
Similar Threads
Validation Using Regular Expression in Javascript
Form does not validated correctly
validating phone number or email id totally through our app
form validator to check for alphabets in a text field
how to prevent ice:commandButton from submitting if there is a validation error