Hello: I have written an ASP.net app that pulls settings from a
database. Part of the setting definition is a regular expression that
I want to use on the client via JavaScript for data validation...
1) Sample code for the setting object:
----------------------------------------------------
function setting(id, name, validationPattern, validationMsg) {
this.id = id;
this.name = name;
this.validationPattern = validationPattern;
this.validationMsg = validationMsg;
}
2) Sample code on the page that creates a new setting object:
----------------------------------------------------
setting(1, 'test', '^\\d{1,1}$|^\\d{2,2}$|^100$', 'invalid value');
3) The issue:
----------------------------------------------------
The setting object gets built just fine except the pattern argument
gets escaped by javascript!!!
^\\d{1,1}$|^\\d{2,2}$|^100$
GETS ESCAPED TO
^\d{1,1}$|^\d{2,2}$|^100$ (Notice how the double \\ is now a single \)
Is there any way for me to preserve the pattern text as is?
Thank you,
zbig555z