<input type="text" name="user_name" placeholder="Please enter your user name" required=""> <input type="text" name="pwd" id="pwd" title="Please enter password at list 8 character and Capital letter and small letter" pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}" required=""> <input type="submit" value="Submit"> </form>
<script type="text/javascript"> var myInput=document.getElementById('pwd'); var letter = document.getElementById("letter"); var capital = document.getElementById("capital"); var number = document.getElementById("number"); var length = document.getElementById("length"); myInput.onfocus= function(){ document.getElementById('message').style.display="block"; } myInput.onblur= function(){ document.getElementById('message').style.display="none"; } myInput.onkeyup= function(){ var lowercaseletters= /[a-z]/g; if(myInput.value.match(lowercaseletters)){ letter.classList.remove('invalid'); letter.classList.add('valid'); } else{ letter.classList.remove('valid'); letter.classList.add('invalid'); }
No comments