asp.net 驗證控制項 :
- 驗證使用者是否輸入資料 (RequiredFieldValidator)
- 驗證 e-mail 格式 (RegularExpressionValidator)
- 驗證 行動電話 格式 (RegularExpressionValidator)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--RegularExpressionValidator_Email--> | |
<asp:TextBox ID="TxtBox_Email" runat="server" Text='<%# Bind("user_email") %>'></asp:TextBox> | |
<!--驗證是否空白--> | |
<asp:RequiredFieldValidator ID="RFVEmail" runat="server" | |
ControlToValidate="TxtBox_Email" | |
ErrorMessage="[請輸入電子郵件帳號!]" Display="Dynamic"> | |
</asp:RequiredFieldValidator> | |
<!--驗證E-mail格式--> | |
<asp:RegularExpressionValidator ID="REVEmail" runat="server" | |
ControlToValidate="TxtBox_Email" | |
Display="Dynamic" ErrorMessage="[請輸入格式正確的電子郵件帳號!]" | |
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"> | |
</asp:RegularExpressionValidator> | |
<!--驗證行動電話格式--> | |
<asp:TextBox ID="TextBox_smartphone" runat="server" Text='<%# Bind("user_smartphone") %>'></asp:TextBox> | |
<asp:RegularExpressionValidator ID="REVSmartphone" | |
runat="server" ErrorMessage="請輸入正確手機號碼" | |
ValidationExpression="((\d{10})|(((\(\d{2}\))|(\d{2}-))?\d{4}(-)?\d{3}(\d)?))" | |
ControlToValidate="TextBox_smartphone" Display="Dynamic"> | |
</asp:RegularExpressionValidator> |
沒有留言:
張貼留言