|
 |
aspx thread: Date Validation.
Message #1 by "raj" <rwave74@y...> on Sun, 15 Dec 2002 07:26:02
|
|
hi guys,
Let me explain my form scenario I have a webform which has to receive
the user entered date. For this i have three dropdownlist. one for day,one
for month, and one for the year.The end user has to select the day from
dropdownlist1 and month from the dropdownlist2 and year from the
dropdownlist3.
my coding is ....
vRecDate = cboMonth_rec.SelectedItem.Value & "-" &
cboDay_rec.SelectedItem.Value & "-" & cboYear_rec.SelectedItem.Value
if not isDate(vRecDate) then
lbl1.text ="InvalidDate"
else
lbl1.text =""
end if
I already checked with isdate() function in the click event of the
command button. it is not working when the user doesn't select the year
still it shows the date is valid. so i need some perfect soultions for
this problem.
thanks in advance
raj
Message #2 by "Mazen Alzogbi" <lists@a...> on Sun, 15 Dec 2002 11:27:45 +0400
|
|
I do recommend using the Calendar Control for this scenario. Why don't
take the advantage of such control including handling events,
validations, etc?
Regards,
Mazen
-----Original Message-----
From: raj [mailto:rwave74@y...]
Sent: Sunday, December 15, 2002 7:26 AM
To: ASP.NET
Subject: [aspx] Date Validation.
hi guys,
Let me explain my form scenario I have a webform which has to
receive
the user entered date. For this i have three dropdownlist. one for
day,one
for month, and one for the year.The end user has to select the day from
dropdownlist1 and month from the dropdownlist2 and year from the
dropdownlist3.
my coding is ....
vRecDate = cboMonth_rec.SelectedItem.Value & "-" &
cboDay_rec.SelectedItem.Value & "-" & cboYear_rec.SelectedItem.Value
if not isDate(vRecDate) then
lbl1.text ="InvalidDate"
else
lbl1.text =""
end if
I already checked with isdate() function in the click event of the
command button. it is not working when the user doesn't select the year
still it shows the date is valid. so i need some perfect soultions for
this problem.
thanks in advance
raj
Message #3 by hi hi <rwave74@y...> on Sun, 15 Dec 2002 20:15:41 -0800 (PST)
|
|
hi mazen,
calender control is big and we need to allocate
seperate space in the web form.can i have any sample
forms with calender control?
thanks in advance
raj
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
Message #4 by "Mazen Alzogbi" <lists@a...> on Mon, 16 Dec 2002 10:16:05 +0400
|
|
Check the following URL:
http://aspalliance.com/search/default.asp?keyword=calendar
Mazen
-----Original Message-----
From: hi hi [mailto:rwave74@y...]
Sent: Monday, December 16, 2002 8:16 AM
To: ASP.NET
Subject: [aspx] RE: Date Validation.
hi mazen,
calender control is big and we need to allocate
seperate space in the web form.can i have any sample
forms with calender control?
thanks in advance
raj
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
Message #5 by "Arjen Oetomo" <arjeno@c...> on Mon, 16 Dec 2002 07:51:18
|
|
You could use a textbox for date-entry and then validate the stringformat
with a regular expression. Its shorter then 3 combo-boxes and works
faster. Keep in mind that you must set the correct CultureInfo for the
date when converting it from string.
' valides dates in the DD/MM/YYYY-format
Public Function ValidateDate(ByVal inputString As String) As Boolean
Dim regEvalString As String = "^(?:(?:31(\/|-|\.)(?:0?[13578]|1
[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0?[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]
\d)?\d{2})$|^(?:29(\/|-|\.)0?2\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468]
[048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1
\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})
$"
Dim regExpVal As System.Text.RegularExpressions.Regex
regExpVal = New System.Text.RegularExpressions.Regex(regEvalString)
return regExpVal.Match(inputString).Success
End Function
> hi guys,
> Let me explain my form scenario I have a webform which has to
receive
t> he user entered date. For this i have three dropdownlist. one for
day,one
f> or month, and one for the year.The end user has to select the day from
d> ropdownlist1 and month from the dropdownlist2 and year from the
d> ropdownlist3.
> my coding is ....
> vRecDate = cboMonth_rec.SelectedItem.Value & "-" &
c> boDay_rec.SelectedItem.Value & "-" & cboYear_rec.SelectedItem.Value
> if not isDate(vRecDate) then
> lbl1.text ="InvalidDate"
e> lse
> lbl1.text =""
e> nd if
>
> I already checked with isdate() function in the click event of the
c> ommand button. it is not working when the user doesn't select the year
s> till it shows the date is valid. so i need some perfect soultions for
t> his problem.
> thanks in advance
r> aj
|
|
 |