![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I am using following function to check for my input my input is like 0.00 i dont want to allow any specialcharacters. function numericValidation() { var x = this; var reg = new RegExp('^[0-9]*\.?[0-9]*$'); ---------------------------------------------^ |
#3
| |||
| |||
|
|
nkle004 (AT) gmail (DOT) com wrote: I am using following function to check for my input my input is like 0.00 i dont want to allow any specialcharacters. function numericValidation() { var x = this; var reg = new RegExp('^[0-9]*\.?[0-9]*$'); ---------------------------------------------^ When calling RegExp as a constructor, quoted special characters in the string literal need two backslashes - you have to quote the quote to get it past the parser (if that makes sense...). Use: var reg = new RegExp('^[0-9]*\\.?[0-9]*$'); Note use of '\\'. |
|
[...] -- Rob |
#4
| |||
| |||
|
|
var reg = /^[0-9]*\.?[0-9]*$/; |
|
"RobG" <rgqld (AT) iinet (DOT) net.au> wrote in message news:0cRNf.599$Nv4.93706 (AT) news (DOT) optus.net.au... nkle004 (AT) gmail (DOT) com wrote: I am using following function to check for my input my input is like 0.00 i dont want to allow any specialcharacters. function numericValidation() { var x = this; var reg = new RegExp('^[0-9]*\.?[0-9]*$'); ---------------------------------------------^ When calling RegExp as a constructor, quoted special characters in the string literal need two backslashes - you have to quote the quote to get it past the parser (if that makes sense...). Use: var reg = new RegExp('^[0-9]*\\.?[0-9]*$'); Note use of '\\'. Or use a regular expression literal: var reg = /^[0-9]*\.?[0-9]*$/; [...] -- Rob |
#5
| |||
| |||
|
|
if i use a regular expression literal can i still use test methos with it ?: var reg = /^[0-9]*\.?[0-9]*$/; |
![]() |
| Thread Tools | |
| Display Modes | |
| |