I am trying to validate the fields in the form and trying to POST the input after validating form the server however I am able to validate the fields but not able to POST the data form the field, please help if anyone could.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<title>Contact Us</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
function readText (form) {
    alert("Please enter your First Name.");
    return false;
	else if(varLname=="")
	alert("Please enter your Last Name.");
	return false;
else if ((varEname.indexOf(".", 0) < 0) || (varEname.indexOf("@", 0) < 0) || varEname=="" || varEname.length < 5)
	alert("Please enter valid E-mail address.");
	return false;
	else if(varComment=="")
	alert("Please enter questions or comments.");
	return false;
	alert ("Form submitted successfully");
	return true;
<FORM NAME="myform" ACTION="http://webdevfoundations.net/scripts/formdemo.asp" METHOD="POST">
	 <fieldset><legend>Questions or Comments:</legend><br />
       <label>First Name: <INPUT TYPE="text" NAME="fName" VALUE=""><br /></label><br />
       <label>Last Name: <INPUT TYPE="text" NAME="lName" VALUE=""><br /></label><br />
       <label>E-Mail:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<INPUT TYPE="text" NAME="eMail" VALUE=""></label> <br /><br />
     </fieldset> <br />
       <label>Questions or Comments:<br /></em>
    <textarea ROWS="4" COLS="60" NAME="comment" VALUE=""></textarea></label><br /><br />
    <INPUT TYPE="Button" NAME="Submit" Value="Submit"onClick=" readText(this.form)"/>  
    <input type="reset" />

Recommended Answers

All 3 Replies

Two issues:-
1. The input type at line 55 should of type "submit"
2. onClick should return true/false to stop/start sending data to server.

Line 55 should be

<INPUT TYPE="submit" NAME="Submit" Value="Submit" onClick="return readText(this.form)"/>

Thank you so much !!! It worked !!

You are welcome.
Please mark this thread as solved!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.