Asp.net date control verification code

Source: Internet
Author: User

Asp tutorial. net date control verification code

<% @ Page Language = VB Debug = true %>
<HTML>
<HEAD>
<TITLE> Comparing a Field to a Date Data Type using the CompareValidator Control </TITLE>
</HEAD>
<Form runat = "server">
<BR>
Please enter a Date: <BR>
<Asp: textbox
Id = "txtDate"
Runat = server
/>
<Asp: comparevalidator
Id = "cvCheckDate"
Controltovalidate = "txtDate"
Operator = "DataTypeCheck"
Type = "Date"
Runat = "server"
>
You must enter a date!
</Asp: CompareValidator> <BR>
<Asp: button
Id = "butOK"
Text = "OK"
Type = "Submit"
Runat = "server"
/>
</Form>
</BODY>
</HTML>


           
      
Check a vb.net verification date code.

<% @ Page Language = VB Debug = true %>
<Script runat = server>
Sub Date_ServerValidation (source As object, E As ServerValidateEventArgs)
If IsDate (E. Value) Then
If Year (E. Value) = Year (Today) Then
E. IsValid = True
Else
E. IsValid = False
End If
Else
E. IsValid = False
End If
End Sub
Sub SubmitBtn_Click (Sender As Object, E As EventArgs)

End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE> Validating for a Date in the Current Year Using the CustomValidator Control </TITLE>
</HEAD>
<Form runat = "server">
<BR>
Enter a date in the current year: <BR>
<Asp: textbox
Id = "txtDate"
Runat = server
/>
<Asp: customvalidator
Id = "customDate"
Controltovalidate = "txtDate"
Onservervalidate = "Date_ServerValidation"
Display = "Dynamic"
Font-name = "Verdana"
Font-bold = "True"
Font-size = "10pt"
Runat = "server">
You must enter a date in the current year!
</Asp: CustomValidator>
<BR>
<Asp: button
Id = "butOK"
Text = "OK"
Type = "Submit"
Onclick = "SubmitBtn_Click"
Runat = "server"
/>
</Form>
</BODY>
</HTML>

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.