开发者

How do I get the Compare Validator to work server side?

开发者 https://www.devze.com 2023-01-14 19:03 出处:网络
I have this compare validator: <asp:CompareValidator ID=\"cpvBirthDate\" Type=\"Date\" ControlToValidate=\"txtBirthDate\" Operator=\"DataTypeCheck\" run开发者_Go百科at=\"server\" ErrorMessage=\"Pl

I have this compare validator:

<asp:CompareValidator ID="cpvBirthDate" Type="Date" ControlToValidate="txtBirthDate" Operator="DataTypeCheck" run开发者_Go百科at="server" ErrorMessage="Please enter a valid date in this format mm-dd-yy">
        <img src="Images/ExclamationMark.gif" alt="Please enter a valid date in this format mm-dd-yy" />
    </asp:CompareValidator>

It works on the clientside fine, but if a user has javascript disabled then it accepts 071873 which is not a date. Do I need to write a specific serverside function for this validator to work?


You have to check Page.IsValid in server code before saving entered data

0

精彩评论

暂无评论...
验证码 换一张
取 消