form กรอกไม่ครบ alert

พูดคุย แลกเปลี่ยน ปัญหา การเขียน JavaScript เครื่องมือ AJAX Web 2.0 AJAX Framework Jquery

Moderator: mindphp

PHP Jr. Member
PHP Jr. Member
Posts: 18
Joined: 11/01/2011 10:10 pm

form กรอกไม่ครบ alert

Post by raccoon »

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<b><font face="Verdana"><font size=+1>Form Validation Example: Feedback Form</font></font></b>
<br><script LANGUAGE="JavaScript">

function ValidateForm(form){
ErrorText= "";
if (form.username.value == "") {ErrorText= "\nPlease enter your name"}

if (( == "" ||'@', 0) == -1) ||'.') == -1){
ErrorText+= "\nPlease enter a proper value for your email"}
if ( == "") {ErrorText+= "\nPlease enter your feedback"}
if (ErrorText!= "") {
alert("Error :" + ErrorText);
return false;
if (ErrorText= "") { form.submit() }


<br><form name="feedback" action="" method=post>
<font face="Verdana">
Please enter the following(To test form validation, skip entering one of the fields and click 'Submit' button):
<font face="Verdana">Name: &nbsp;</font><input type="text" value="" name="username" size=30></dt>
<dt> <font face="Verdana">E-mail: &nbsp;</font><input type="text" value="" name="email" size=30></dt>
<dt> <font face="Verdana">Feedback:</font></dt>
<dt><textarea rows=7 cols=60 name="feedback"></textarea></dt>
<input type="button" name="SubmitButton" value="Submit" onClick="ValidateForm(this.form)">
<input type="reset" value="Reset">
<pre><font face="Verdana"><font size=+0>&nbsp; &nbsp;</font></font>
  • Similar Topics
    Last post

Return to “JavaScript & Jquery Ajax”

Who is online

Users browsing this forum: No registered users and 3 guests