Question

Password must begin with a capital letter followed by exactly 6 alphanumeric letters followed by a...

Password must begin with a capital letter followed by exactly 6 alphanumeric letters followed by a single numeric digit. Write Javascript code to validate this and similarly display error message if violated. Valid: Pabcdef8, J1234567, Ka1b2c39, Invalid: abcdefg9, Abcdefgh, Abcdefg78. I must not be using the right special characters form validation. Can you tell me the format for the password in special characters as shown below? I've bolded the particular part of code.

HTML:

<label for="password"><br>Password: </label>
<input type="password" id="password" name="password">&#42;<br><br>

JAVASCRIPT:

function chkname3(){

//assign var to value
var love3 = document.getElementById("password");

var sortname3 = love3.value.search(/[A-Z]0-9a-zA-Z{6, }\D\d\D/);

if(sortname3 != 0){
alert("message");
return false;
}
else
return true;
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

JAVASCRIPT:

function chkname3() {
    //assign var to value
    var love3 = document.getElementById("password");
    var sortname3 = love3.value.search(/[A-Z][0-9a-zA-Z]{6}[0-9]/);
    if (sortname3 != 0) {
        alert("message");
        return false;
    } else return true;
}

You can also put /[A-Z][\da-zA-Z]{6}\d/ in the search function.

FOR ANY HELP JUST DROP A COMMENT

Add a comment
Know the answer?
Add Answer to:
Password must begin with a capital letter followed by exactly 6 alphanumeric letters followed by a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT