<script type="text/javascript">
// at least one number, one lowercase and one uppercase letter
// at least six characters
var re = /(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,}/;
var validPassword = re.test(input);
</script>
Hi guys i have this input validation for password. However, I am not sure how do I insert an input box and a submit button which calls the check.
Currently I have a input box and submit button which will have errors if compiled.
If you have HTML along the lines of the following:
Then you can use JavaScript such as the following:
This simply attaches a click event handler to the submit button, and tests the regular expression against the value of the input. If the regex matches, the form will submit as normal. If not,
falsewill be returned and the form will not submit.Here’s a working example.