A set of characters must be specified within []
The RegExp constructor is not needed for this exercise but I have retained it:
Code:
<script type="text/javascript">
var password = '@2';
var re = new RegExp("[!@#$%^&*]");
if(!re.test(password))
alert("No special characters");
re = new RegExp("[0123456789]");
if(!re.test(password))
alert("No digits");
</script>
Where used, return should be executed unconditionally and always as the last statement in the function.
That's my signature, it's not part of the damn post!
Bookmarks