\s does not work for javascript ???

  • Thread starter Thread starter zhuang
  • Start date Start date
Z

zhuang

Hi,

I try to use javascript for validation,

re = new RegExp("^(([a-zA-Z]|\s)+)$");

but it does not work, problem comes from \s, but \s works well with
RegularExpressionValidator control.

Surprisly, if I just use a space instead of \s, it works.

I searched some javascript tutorial on line, they all say \s is the
right thing.

Could anyone give me a answer?

Thanks lot

zhuang
 
Doesn't \ need to be escaped in Javascript?

re = new RegExp("^(([a-zA-Z]|\\s)+)$");

Note the double \\.

I could be wrong, though.
 
Back
Top