File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "validation" Watch "validation" New topic
Author

validation

Saurabh Naik
Ranch Hand

Joined: Apr 24, 2008
Posts: 87
Hello
How to make validation for allowing only numbers. suppose in my form there is field named phone no. so numbers should be allowed in it and not text.
so is there any built in function in java script ? or how to make use of regex in this case .


SCJP 6 (88%), SCWCD 5 (78%), preparing for SCBCD
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30400
    
150

There are many examples online. Have you tried searching yet?

A quick search showed me a regular expression in JavaScript for zip code. Phone numbers are similar - logic varies by region though.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


Start here for regex basics.



As Jeanne pointed out, phone number varies in region-wise , code your regex pattern and test() like the code above.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: validation