ISHAN MAHAJAN - 11 months ago 41
Javascript Question

I am using this script don't know how it works but it makes neccessary for a user to use a capital letter and a lower case alphabet

<input title="Password must contain at least 6 characters, including UPPER/lowercase and numbers" type="password" required pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,20}" maxlength="20" name="password" onchange="
this.setCustomValidity(this.validity.patternMismatch ? this.title : '');
this.setCustomValidity(this.validity.patternMismatch ? this.title : '');"  placeholder="Confirm Password" maxlength="20" id="confirm_password">

And I wanted that user can either input a speacial character or a Capital letter so I replaced
[A-Z]
with
[A-Z~@#$^*()_+=[\]{}|\\,.?: -] but it is still expecting a Capital letter and a lowercase letter. My question is how to allow user to input either a Speacial character or A Capital letter. In my example if user wants to submit a Speacial character he is not allowed to do so how do I overcome that. Answer Source You can go with this: <form name="form1" action="#"> <ul> <li><input type="password" name="pwd1"/></li> <li>&nbsp;</li> <li class="submit"><input type="submit" name="submit" value="Submit" onclick="CheckPassword(document.form1.pwd1)"/></li> <li>&nbsp;</li> </ul> </form>  Javascript: function CheckPassword(inputtxt) { var passw= /^[A-Za-z]\w{7,14}$/;
if(inputtxt.value.match(passw))
{