[SOLVED] Use RegExpValidator to validate strings
-
I want to check if a string is valid with regular expression. I have found the RegExpValidator object, but only with sample where a TextInput is used. How do I use this to just validate a string? I want to have something like this:
@
RegExpValidator
{
id: regexpValidator;
regExp: /[0-9]+/
}function test() { var textIsValid = regexpValidator.regExp.validate("Hello world!", 0); }
@
-
Hi,
Use the regexp directly:
@
function test()
{
var regExp = /[0-9]+/;
var textIsValid = regExp.test("Hello world!");
}
@ -
Oh… that was simple! Thanks! :-)