hi I am trying to to validate a text box using javascript reguler expressions. what i am trying to do is text box value must start with $ symbol and after $ symbol text box must validate numbers only. please help me for this,i need it urgent.
@disgracianJan 06.2007 — #[b]var regEx = /^$d{1,}/;[/b] would probably work. I'm not sure if you have to escape the '$' symbol with a preceding backslash or not.
To use this to actually validate a string of text, use [b]regEx.test([i]variable_name[/i]);[/b] and this will return true if the string matches the regular expression and false if it doesn't.
Cheers,
D.
EDITED TO ADD: If you're working with currency which it seems you are, you're probably going to want to add a decimal point at some stage, in which case I'd modify the above to read:
@OverstatementJan 06.2007 — #disgracian seemed to have misplaced one of his shashes () one character to the left. What he really meant was: <i> </i>/^$d*(.d{2})?$/
I think $.23 is a valid was of writing a number but most people probably don't use $123.456