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>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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;
    }
    }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

HTML Form example

A

Name:

How well did you know this?
1
Not at all
2
3
4
5
Perfectly