Asp. NET Regularexpressvalidator (regular validation) use

Source: Internet
Author: User

Original: ASP. NET Regularexpressvalidator (regular validation) use

Use of Ylbtech-asp.net-control-validator:regularexpressvalidator (regular validation)

Asp. NET in Regularexpressvalidator (regular validation) use.

1.A, running effect back to top
RegularExpressionValidator: The Regular validation attribute:
ControlToValidate: The control to validate
ErrorMessage: Error message
ValidationExpression: Regular Expressions

1,
ID Number:The Province certificate number is wrong

2, ZIP Code:Postcode wrong

3, phone number:Wrong phone number

4, e-mail: e-Mail error

5, website (URL):URL Error


1.B, source code back to top
/demo3.aspxView Code
<%@ Page Language="C #"AutoEventWireup="true"CodeFile="Demo3.aspx.cs"Inherits="Demo3" %><!DOCTYPE HTML Public "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd "><HTMLxmlns= "http://www.w3.org/1999/xhtml"><Headrunat= "Server">    <title>No title page</title></Head><Body>    <formID= "Form1"runat= "Server">    <Div>    <H2>RegularExpressionValidator: Regular validation</H2>    <HR/>Properties:<BR/>ControlToValidate: The control to validate<BR/>errormessage: Error message<BR/>ValidationExpression: Regular Expressions<BR/>        <HR/>            <BR/>1,<BR/>ID Number:<Asp:textboxID= "txtID"runat= "Server"></Asp:textbox>        <Asp:regularexpressionvalidatorID= "RegularExpressionValidator1"runat= "Server"ControlToValidate= "txtID"errormessage= "The province certificate number is wrong"ValidationExpression= "\d{17}[\d| X]|\D{15} "></Asp:regularexpressionvalidator>        <BR/>        <BR/>2, ZIP code:<Asp:textboxID= "Txtzipcode"runat= "Server"></Asp:textbox>        <Asp:regularexpressionvalidatorID= "RegularExpressionValidator2"runat= "Server"ControlToValidate= "Txtzipcode"errormessage= "Postcode is wrong"ValidationExpression= "\d{6}"></Asp:regularexpressionvalidator>        <BR/>        <BR/>3, phone number:<Asp:textboxID= "Txttel"runat= "Server"></Asp:textbox>        <Asp:regularexpressionvalidatorID= "RegularExpressionValidator3"runat= "Server"ControlToValidate= "Txttel"errormessage= "wrong phone number"ValidationExpression= "(\ (\d{3}\) |\d{3}-)? \d{8}"></Asp:regularexpressionvalidator>        <BR/>        <BR/>4, e-mail:<Asp:textboxID= "Txtemail"runat= "Server"></Asp:textbox>        <Asp:regularexpressionvalidatorID= "RegularExpressionValidator4"runat= "Server"ControlToValidate= "Txtemail"errormessage= "e-mail is wrong"ValidationExpression= "\w+ ([-+. '] \w+) *@\w+ ([-.] \w+) *\.\w+ ([-.] \w+) * "></Asp:regularexpressionvalidator>        <BR/>        <BR/>5, website (URL):<Asp:textboxID= "Txturl"runat= "Server"></Asp:textbox>        <Asp:regularexpressionvalidatorID= "RegularExpressionValidator5"runat= "Server"ControlToValidate= "Txturl"errormessage= "URL is wrong"ValidationExpression= "http (s)?:/ /([\w-]+\.) +[\w-]+ (/[\w-./?%&amp;=]*)? "></Asp:regularexpressionvalidator>        <BR/>        <BR/>        <BR/>        <Asp:buttonID= "Button1"runat= "Server"Text= "Submit" />        <BR/>        </Div>    </form></Body></HTML>
1.C, Resources download back to top

Http://files.cnblogs.com/ylbtech/WebForm-BasicControl-Validator.rar

Ylbtech
Source: http://ylbtech.cnblogs.com/
This article is copyright to the author and the blog Park, Welcome to reprint, but without the consent of the author must retain this paragraph, and in the article page obvious location to the original link, otherwise reserves the right to pursue legal responsibility.

Asp. NET Regularexpressvalidator (regular validation) use

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.