日期格式的验证问题 [英] Validation problem in date format
问题描述
嗨朋友
如何在asp.net中创建验证日期格式dd-mm-yyyy
我创建
< asp:RegularExpressionValidator ID = RegularExpressionValidator4 runat = 服务器 ForeColor = 红色
ControlToValidate = txtDateofBirth ValidationGroup = 检查 ErrorMessage = DD / MM / YYYY中的日期格式
< span class =code-attribute> ValidationExpression = ^( ((((0 [1-9])|(1\d)|(2 [0-8]))\ /((0 [1-9])|(1 [0-2])) )|((31\ /((0 [13578])|(1 [02])))|((29 | 30)\ /((0 [1,3-9])|(1 [0 -2])))))\ /((20 [0-9] [0-9])|(19 [0-9] [0-9])))|((29\ / 02\\ \\ /(19 | 20)(([048])|([13579] [26]))))$ > < / asp:RegularExpressionValidator >
我插入错误的日期它正常工作并收到错误消息但是当我点击提交按钮时这条记录被插入数据库
所以请帮助我
> < / asp:RegularExpressionValidator >
我插入错误的日期它正常工作并收到错误信息但当我点击提交按钮时此记录被插入数据库
所以请帮帮我
引用:并插入错误的日期,它正常工作并收到错误信息但是当我点击提交按钮此记录插入数据库
在提交按钮中检查Page.IsValid
在将记录插入数据库之前单击。
if (Page.IsValid)
{
// 您的插入代码。
}
Hi friends
How to create validate date format dd-mm-yyyy in asp.net
I create
<asp:RegularExpressionValidator ID="RegularExpressionValidator4" runat="server" ForeColor="Red"
ControlToValidate="txtDateofBirth" ValidationGroup="check" ErrorMessage="Date format in DD/MM/YYYY"
ValidationExpression="^(((((0[1-9])|(1\d)|(2[0-8]))\/((0[1-9])|(1[0-2])))|((31\/((0[13578])|(1[02])))|((29|30)\/((0[1,3-9])|(1[0-2])))))\/((20[0-9][0-9])|(19[0-9][0-9])))|((29\/02\/(19|20)(([02468][048])|([13579][26]))))$"></asp:RegularExpressionValidator>
and I insert wrong date it work properly and get error message but when I click submit button this record are insert in database
So please help me
"></asp:RegularExpressionValidator>
and I insert wrong date it work properly and get error message but when I click submit button this record are insert in database
So please help me
Quote:and i insert wrong date it work properly and get error message but when i click submit button this record are insert in database
CheckPage.IsValid
in your Submit button click before inserting record into Database.
if (Page.IsValid) { //Your Insert Code. }
这篇关于日期格式的验证问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!