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

Post a reply

:icon_plusone: :like: :plusone: :gfb: :-D :) :( :-o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: :angry: :baa: :biggrin:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review

Expand view Topic review: form กรอกไม่ครบ alert

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

by raccoon » 11/01/2011 10:21 pm

<!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>