Hello,

This is one of the important validation that you need to take care, when user enter's data in form.

Most of the time user tries to enters his/her birth date higher than today's date, so this is poor validation.

Please find few line code below that will help you comparing users birth date which should be lower than today's date.

//---------------code of code behind -------------------

If Trim(txtBirthDate.Text) = "" Then
Else
Dim textboxdate As Date = Convert.ToDateTime(txtBirthDate.Text).Date
Dim todaysdate As Date = DateTime.Now.Date
If textboxdate >= todaysdate Then
datelabel.Visible = True
datelabel.Text = "Birth date must Not be greater than today's Date"
flag = False
End If
End If

//------------------ code ends -------------------------


//---------------code for front end --------------------

<td>
<div id="datediv">
<asp:Label ID="datelabel" runat="server"></asp:Label>
</div>
</td>>

//-------------------code ends -------------------------

Hope this post will help you,
Rajesh Singh,
Asp.Net Developer
Indianic Infotech ltd (India)
rajesh@indianic.com

0 comments