Form Validation in VBScript
<HEAD>
<SCRIPT LANGUAGE="VBSCRIPT">
<!--
Sub Button1_onclick
If Form1.elements(0).value <> "" Then
If Form1.elements(1).value <> "" Then
If Form1.elements(2).value <> "" Then
' OK, all of the fields have some value entered.
' Now check email address for '@' and '.' characters
If InStr(Form1.elements(1).value, "@") <> 0 Then
If InStr(Form1.elements(1).value, ".") <> 0 Then
Form1.Submit
Else
alert "Your email address must contain a '.' character."
End If
Else
alert "Your email address must contain a '@' character."
End If
Else
alert "Please fill out the 'Phone' field"
Form1.elements(2).focus
End IF
Else
alert "Please fill out the 'Email' field"
Form1.elements(1).focus
End If
Else
alert "Please fill out the 'Name' field"
Form1.elements(0).focus
End If
End Sub
-->
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME="Form1" ACTION="08_submit2.htm">
<TABLE WIDTH=500 CELLPADDING=0 CELLSPACING=3 COLS=2 BORDER=0>
<TR>
<TD ALIGN=RIGHT VALIGN=TOP WIDTH=50>
<FONT FACE="Verdana, Arial, Helvetica" SIZE=2>
Name:
</FONT>
</TD>
<TD ALIGN=LEFT VALIGN=TOP WIDTH=450>
<INPUT TYPE=TEXT SIZE=40 NAME="txtName">
</TD>
</TR>
<TR>
<TD ALIGN=RIGHT VALIGN=TOP>
<FONT FACE="Verdana, Arial, Helvetica" SIZE=2>
Email:
</FONT>
</TD>
<TD ALIGN=LEFT VALIGN=TOP>
<INPUT TYPE=TEXT SIZE=40 NAME="txtEmail">
</TD>
</TR>
<TR>
<TD ALIGN=RIGHT VALIGN=TOP>
<FONT FACE="Verdana, Arial, Helvetica" SIZE=2>
Phone:
</FONT>
</TD>
<TD ALIGN=LEFT VALIGN=TOP>
<INPUT TYPE=TEXT SIZE=40 NAME="txtPhone">
</TD>
</TR>
<TR>
<TD ALIGN=LEFT VALIGN=TOP WIDTH=100% COLSPAN=2>
<INPUT TYPE=BUTTON VALUE="Submit" NAME="Button1">
</TD>
</TABLE>
</TABLE>
</FORM>