A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Java SE 8 for the Really Impatient
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
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
How To Ask Questions The Smart Way
Blogging on Certs:
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.
I agree. Here's the link:
[URLyBird] gui user input validation
loop through a string
Multiple redirect to the same server
Struts2 Validation - Number?
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014