Click to See Complete Forum and Search --> : Generate regular expression ???


shanuragu
08-23-2003, 04:39 AM
Hi

can any one tell me how to generate a regular expression for validation of a text filed with the following conditions.

It can have any number of digits with either "," or "." (cannot repeat more than once) and should not start or end from "," or "." also no character or special charecters allowed.

please help

shara

Fang
08-23-2003, 05:20 AM
function Validate(strValue) {
var objRegExp=/^\d+[\.,]?[\d]+$/;
alert(objRegExp.test(strValue));
}

shanuragu
08-25-2003, 08:50 AM
Thanks for the help Fang!!.
I need another regular expression for a text box with fllowing conditions (the number can be in any of the following form)
1. Can have both "," and "." (not more than one set)
2. should start & end with a number
3. "," and "." should not be together (not 1.,3)
4. can use "," only when the no is more than 3 digits

Is it possible ??

I get confused a lot with this regular expressions (like how to give conditions for allow one "." or "'" & so on...). Any suggestions & short cuts for generating regular expression???

Suggestions & web links about Regular expressions are most wel come.

shara
:confused: :D

Jeff Mott
08-25-2003, 01:35 PM
/^\d{1,3}(?:,\d{3})*\.\d*$/

(untested)