I want to use JavaScript (can be with jQuery) to do some client-side validation to check whether a string matches the regex:
^([a-z0-9]{5,})$
Ideally it would be an expression that returned true or false.
I'm a JavaScript newbie, does match()
do what I need? It seems to check whether part of a string matches a regex, not the whole thing.
I would recommend using the execute method which returns null if no match exists otherwise it returns a helpful object.
Here's an example that looks for certain HTML tags so it's clear that
/someregex/.test()
returns a boolean:try
please try this flower:
Use
test()
method :