File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
REST with Spring (video course)
this week in the
Joined: Apr 24, 2008
May 10, 2009 07:36:13
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
script ? or how to make use of regex in this case .
SCJP 6 (88%), SCWCD 5 (78%), preparing for SCBCD
author & internet detective
Joined: May 26, 2003
May 10, 2009 08:08:37
There are many examples online. Have you tried searching yet?
A quick search showed me a
OCA 8 book
How To Ask Questions The Smart Way
SCEA Part 1
Part 2 & 3
Core Spring 3
TOGAF part 1
Joined: Jan 01, 2009
May 10, 2009 09:43:08
Start here for
var pat=new RegExp("^[0-9]$"); // create your regex pattern here document.write(pat.test("121231")); // this simply checks for digits in any order in any length
As Jeanne pointed out, phone number varies in region-wise , code your regex
() like the code above.
It is sorta covered in the
JavaRanch Style Guide
[URLyBird] gui user input validation
loop through a string
Struts2 Validation - Number?
Multiple redirect to the same server
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015