Running Environment: Win2000 Advance Server + IIS5.0 + ngws sdk (80 m ).
The function used to verify the email address uses the code in Liao Xiong's essence area.
<% @ Page Language = "C #" %>
<Html>
<Script language = "javascript">
Function ClientValidateEmail (source, value)
{
Var strr;
Re =/(w + @ w +. w +) (. {0, 1} w *) (. {0, 1} w *)/I;
Re.exe c (value );
If (RegExp. $3! = "" & RegExp. $3! = "." & RegExp. $2! = ".") Strr = RegExp. $1 + RegExp. $2 + RegExp. $3
Else
If (RegExp. $2! = "" & RegExp. $2! = ".") Strr = RegExp. $1 + RegExp. $2
Else strr = RegExp. $1
If (strr! = Value)
Return false;
Else
Return true;
}
</Script>
<Body>
<H3> ASP. NET user input verification
<Form method = post runat = server>
<Hr width = 600 size = 1 noshade>
<Table>
<Tr>
<Td>
<Asp: ValidationSummary ID = "valSum" runat = "server"
HeaderText = "you must enter the following form fields :"
DisplayMode = "bulletlist"
Font-Name = ""
Font-Size = "12"
/>
</Td>
</Tr>
</Table>
<Center>
<P>
<! -- Login information -->
<Table border = 0 width = 600>
<Tr> <td colspan = 3>
<Table border = 0 cellpadding = 0 cellspacing = 0 width = "100%">
<Tr> <td>
<B> Logon Information </B>
</Td> </tr>
</Table>
</Td> </tr>
<Tr>
<Td align = right>
Email Address:
</Td>
<Td>
<Asp: TextBox id = email width = 200px maxlength = 60 runat = server/>
</Td>
<Td>
<Asp: RequiredFieldValidator id = "emailReqVal"
ControlToValidate = "email"
ErrorMessage = "Email address"
Display = "Dynamic"
Font-Name = ""
Font-Size = "12"
Runat = server>
*
</Asp: RequiredFieldValidator>
<Asp: CustomValidator id = "emailRegexVal" runat = "server"
ControlToValidate = "email"
ClientValidationFunction = "ClientValidateEmail"
Display = "Static"
Font-Name = ""
Font-Size = "12">
Invalid Email address
</Asp: CustomValidator>
</Td>
</Tr>
<Tr>
<Td align = right>
Password:
</Td>
<Td>
<Asp: TextBox id = passwd TextMode = "Password" maxlength = 20 runat = server/>
</Td>
<Td>
<Asp: RequiredFieldValidator id = "passwdReqVal"
ControlToValidate = "passwd"
ErrorMessage = "User Password"
Display = "Dynamic"
Font-Name = "" Font-Size = "12"
Runat = server>
*
</Asp: RequiredFieldValidator>
<Asp: RegularExpressionValidator id = "passwdRegexBal"
ControlToValidate = "passwd"
ValidationExpression = ".*[! @ # $ % ^ & * +;:]. *"
Display = "Static"
Font-Name = "" Font-Size = "12"
Width = "100%" runat = server>
The password must contain the following characters :(! @ # $ % ^ & * + ;:)
</Asp: RegularExpressionValidator>
</Td>
</Tr>
<Tr>
<Td align = right>
Confirm Password
</Td>
<Td>
<Asp: TextBox id = passwd2 TextMode = "Password" maxlength = 20 runat = server/>
</Td>
<Td>
<Asp: RequiredFieldValidator id = "passwd2ReqVal"
ControlToValidate = "passwd2"
ErrorMessage = "Confirm Password"
Display = "Dynamic"
Font-Name = "" Font-Size = "12"
Runat = server>
*
</Asp: RequiredFieldValidator>
<Asp: CompareValidator id = "CompareValidator1"
ControlToValidate = "passwd2" ControlToCompare = "passwd"
Display = "Static"
Font-Name = "" Font-Size = "12"
Runat = server>
Invalid password
</Asp: CompareValidator>
</Td>
</Tr>
<Tr> <td colspan = 3> </td> </tr>
<! -- Private information -->
<Tr> <td colspan = 3>
<Table border = 0 cellpadding = 0 cellspacing = 0 width = "100%">
<Tr> <td>
<B> Personal Information </B>
</Td> </tr>
</Table>
</Td> </tr>
<Tr>
<Td align = right>
Name:
</Td>
<Td>
<Asp: TextBox id = pname maxlength = 20 width = 200px runat = server/>
</Td>
<Td>
</Td>
</Tr>
<Tr>
<Td align = right>
Address:
</Td>
<Td>
<Asp: TextBox id = address width = 200px runat = server/>
</Td>
<Td>
</Td>
</Tr>
<Tr>
<Td align = right>
Zip code:
</Td>
<Td>
<ASP: TextBox id = postcode width = 60px maxlength = 6 runat = server/>
</Td>
<Td>
<Asp: RegularExpressionValidator id = "RegularExpressionValidator1"
ControlToValidate = "postcode"
ValidationExpression = "^ d {6} $"
Display = "Static"
Font-Name = "" Font-Size = "12"
Runat = server>
The zip code must be 6 digits
</Asp: RegularExpressionValidator>
</Td>
</Tr>
<Tr>
<Td align = right>
Gender:
</Td>
<Td>
<ASP: RadioButtonList id = sexType runat = server>
<Asp: ListItem> male </asp: ListItem>
<Asp: ListItem> female </asp: ListItem>
</ASP: RadioButtonList>
</Td>
<Td>
<Asp: RequiredFieldValidator id = "sexTypeReqVal"
ControlToValidate = "sexType"
ErrorMessage = "gender"
Display = "Static"
InitialValue = ""
Font-Name = "" Font-Size = "12"
Runat = server>
*
</Asp: RequiredFieldValidator>
</Td>
</Tr>
<Tr>
<Td align = right>
Year of birth:
</Td>
<Td>
<ASP: DropDownList id = expYear runat = server>
<Asp: ListItem> </asp: ListItem>
<Asp: ListItem> 1976 </asp: ListItem>
<Asp: ListItem> 1975 </asp: ListItem>
</ASP: DropDownList>
</Td>
<Td>
<Asp: RequiredFieldValidator id = "expDateReqVal"
ControlToValidate = "expYear"
ErrorMessage = "Year of birth"
Display = "Static"
InitialValue = ""
Font-Name = "" Font-Size = "12"
Runat = server>
*
</Asp: RequiredFieldValidator>
</Td>
</Tr>
</Table>
<P>
<Input runat = "server" type = submit value = "submit">
<P>
</Form>
</Center>
</Body>
</Html>