Generation

generate functionMon, 27 Mar 2023

B. write Javascript code to add the following validations 1. All the text boxes should have required field validator 2. Email Address and Re-enter Email should match 3. First and last name should only accept characters 4. State Code should contain only 2 Characters 5. 5 Digit Zip Code contain only characters and numbers and the length should be 5

<!DOCTYPE html> <html> <head> <title>Registration</title> <script type="text/javascript"> function validate() { var email = document.getElementById("email").value; var email2 = document.getElementById("email2").value; var first = document.getElementById("first").value; var last = document.getElementById("last").value; var state = document.getElementById("state").value; var zip = document.getElementById("zip").value; var errors = 0; if (email == "") { document.getElementById("emailErr").innerHTML = "Please enter your email." errors += 1; } else if (email2 == "") { document.getElementById("emailErr").innerHTML = "Please re-enter your email." errors += 1; } else if (email != email2) { document.getElementById("emailErr").innerHTML = "

Javascript
Generate More

Questions about programming?Chat with your personal AI assistant