<script type="text/javascript" > function validate() { var msg; if(document.myForm.userPass.value.length>5){ msg="good"; } else{ msg="poor"; } document.getElementById('mylocation').innerText=msg; } </script> <form name="myForm"> <input type="password" value="" name="userPass" onkeyup="validate()"> Strength:<span id="mylocation">no strength</span> </form>
Question
<script type="text/javascript" > function validate() { var msg; if(document.myForm.userPass.value.length>5){ msg="good"; } else{ msg="poor"; } document.getElementById('mylocation').innerText=msg; } </script> <form name="myForm"> <input type="password" value="" name="userPass" onkeyup="validate()"> Strength:<span id="mylocation">no strength</span> </form>
Solution
This is a JavaScript code snippet. It's a function that validates the length of a password. If the length of the password is more than 5 characters, it displays "good". Otherwise, it displays "poor". This function is called every time a key is released in the password input field. The result is displayed in the HTML element with the id 'mylocation'.
Similar Questions
Design a login form using HTML & JavaScript with following validations usingRegular Expression on username and password fields.1. Username and Password should not be both blank2. Username should not start with digit,_, @ or #3. Password length must be 8 to 16 characters
can you write a code to validate form using php i have the html code only
Write a JavaScript program to validate an Email address
function validateSearch() { var query = document.getElementById('search-input').value; if (query.trim() === '') { alert('Please enter a search term.'); return false; } return true;
As a programmer for JScript, Inc., you have been assigned to a team to develop a Web site for IT support requests. The Web designer you are working with is good at the visual aspects of the Web forms, but lacks the knowledge to implement the JavaScript code for form validation. There is a new ticket submission form that needs validation. The data on the form and field names are shown below.Ticket Input Form DataReqDate (request date, required, must be mm/dd/yyyy format)EmpID (employee ID, required, must be 6 alphanumeric characters, starting with a capital letter, followed by 5 numbers)FName (user first name, required, must start with capital letter)LName (user last name, required, must start with capital letter)ProbDesc (problem description, required)Your task is to write the JavaScript code for appropriate input validation for this form. The validation code for the form will be in a function called validateInputForm(form) where the form parameter is an object with access to each form field by the names given in the list for each form. The function will return true if the form input is valid, or false if the form input is invalid. The function will be responsible for issuing appropriate alert messages for any invalid input, and should return after finding the first invalid input and notifying the user. The validation function should use if statements and regular expressions where appropriate to validate the input.
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.