Create an HTML form that asks the user for these items:
First Name
Last Name
Number of Pets in their home
Their opinion about who will win the Super Bowl this season. (You can make this
element a textarea, some radio buttons, some checkboxes, or even a selection
list. It's your choice.)
Save your form page as Form2.html
Put some JavaScript code in Form2.html, which verifies that:
First Name and Last Name have been entered.
Number of Pets has been entered.
Number of Pets is a number.
Number of Pets is not a negative number. But it can be zero.
Their opinion has been entered.
Code the action attribute of your <form> tag so it sends
the form's data to my PHP "display" page. Use this URL:
https://www.jimlink.net/PHPStuff/testFormData.php
My PHP action page will simply display your form's variables' (input fields') information.
If any of the verified items is not entered properly, ask the user (you can
use an alert( ) window) to fill in the missing or incorrect information.
This is important: If any of the verified items is not entered properly, cancel
the form's submission, meaning that the form's action page should
not display.
If the data are correct, allow the form submission to proceed. In other words, allow
my PHP data display page to open.
Hints:
The phrase 'Code the action attribute...' should suggest to
you something to do with the action attribute of the <form> tag.
Because the school server sometimes prevents the use of method="post" in
your <form> tag, you might have to use method="get" for this assignment.
The onsubmit attribute/event handler is in the form tag.
You can use the escape character sequence "\n" to put a newline (return)
character into a JavaScript string that will be displayed to the screen in an
"alert" popup window.
Add a hypertext link to the
index.html file that is in your class folder. Make this hypertext
link display the html page that you made for this assignment.
Validate your page using the
W3C HTML Validator.
(The Validator will automatically detect whether you have an XHTML or an HTML5
document.)
Upload your files to your class folder. You will
need to use an FTP program to upload the files. You will find
some general FTP instructions on a page called "FTP
Instructions".