Guided Practice with HTML Form Validation, Part 2 Flashcards
1
Q
action attribute
A
- specifies where to send the form-data when a form is submitted
- On submit, send the form-data to a file named “/action_page.php” (to process the input):
First name: <br></br>
Last name: <br></br>
2
Q
JavaScript Form Validation
A
- HTML form validation can be done by JavaScript.
- If a form field (fname) is empty, this function alerts a message, and returns false, to prevent the form from being submitted:
function validateForm() {
var x = document.forms[“myForm”][“fname”].value;
if (x == “”) {
alert(“Name must be filled out”);
return false;
}
}
3
Q
HTML Form example
A
Name: