\s does not work for javascript ???

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
 
C

Chris Dunaway

Doesn't \ need to be escaped in Javascript?

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

Note the double \\.

I could be wrong, though.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top