0
Regex validation of username and password in js
I am trying to use regex to validate username and password I got error see the code below in html and JavaScript https://code.sololearn.com/WwRPuK7ZFuMi/?ref=app
3 Answers
+ 1
The validation function is not defined. Instead of calling the function validation, the onsubmit attribute of the form element should call the CheckPassword function, like so: onsubmit="return CheckPassword()"
The CheckPassword function takes in an argument called inputtxt, but it is not being passed in when the function is called in the onsubmit attribute. To fix this, the onsubmit attribute should call the CheckPassword function with the correct input, like so: onsubmit="return CheckPassword(this.password)"
The regular expression for the password validation is missing the forward slashes (/) at the beginning and end of the expression. These forward slashes are required to create a regular expression object in JavaScript. The regular expression should be updated to look like this: var password = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,20}$/;
Coding Try this code
https://code.sololearn.com/WVYg4IOexI8g/?ref=app
+ 4
Coding
put given username and password inside single or double quotes.
0
Thanks