I have 2 html files, fillForm.html, and AnswerForm.html, and a javascript file called scripts.js I want to create a form in the fillForm page, with name and age, and when I click Submit, I want to check that all the form as been filled up, and send the data to the second page, That will present on screen: " Hello "name", your Age is "age" " I think it something with request and response, but I want to do it with post, and not take data from the url with get. I have this in the fillForm page:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="scripts.js"></script>
<script src="http://ajax.microsoft.com/ajax/jQuery/jquery-1.8.2.js"
type="text/javascript"></script>
</head>
<body>
<form name="myForm" action="AnswerForm.html" onsubmit="return validateForm()" method="post">
First name: <input type="text" name="fname"><br/>
Age: <input type="text" name="age">
<input type="submit" value="Submit">
</form>
</body>
</html>
And the script in scripts.js is:
function validateForm()
{
var firstName=document.forms["myForm"]["fname"].value;
var Age=document.forms["myForm"]["age"].value;
if ((firstName==null || firstName=="") || (Age==null || Age==""))
{
alert("fillOut all the form");
return false;
}
else
{
}
}
Know I just want to take the data and show it on ANSWERFORM.html and here I need help. Also I have a question: Is the check of the form is good or maybe there is a better way to check? Because if I have not 2 data to check but 40, This checking will be very long, and also the checking is not specific but general) Thank you!