Validation in ASPX

P

Paul King

Hi there,

I have a RequiredFieldValidator for one of my ASP textboxes. In addition, I
have another TextBox where the user can enter date information. I would
therefore like to validate the input so that only the format dd/mm/yy is
correct.

At present, if someone types a character in this field, a SQL error message
occurs - which isn't that helpful to the user.

Any ideas?

Thanks
Paul
 
H

Hans Kesting

Paul King said:
Hi there,

I have a RequiredFieldValidator for one of my ASP textboxes. In addition, I
have another TextBox where the user can enter date information. I would
therefore like to validate the input so that only the format dd/mm/yy is
correct.

At present, if someone types a character in this field, a SQL error message
occurs - which isn't that helpful to the user.

Any ideas?

Thanks
Paul

1) CompareValidator with Operator set to DataTypeCheck and Type set to Date
BUT: I'm not sure exactly what syntax is used.

2) CustomValidator with server side code trying to parse the date

Hans Kesting
 
P

Paul King

Thanks Hans,

In this case I resolved it using the RegularExpressionValidator
and inserted the correct syntax under the ValidationExpression

Many thanks for your help
Paul.
 
S

Shiva

Another option is RegularExpressionValidator.

Hi there,

I have a RequiredFieldValidator for one of my ASP textboxes. In addition, I
have another TextBox where the user can enter date information. I would
therefore like to validate the input so that only the format dd/mm/yy is
correct.

At present, if someone types a character in this field, a SQL error message
occurs - which isn't that helpful to the user.

Any ideas?

Thanks
Paul
 
H

Hans Kesting

Paul King said:
Thanks Hans,

In this case I resolved it using the RegularExpressionValidator
and inserted the correct syntax under the ValidationExpression

Many thanks for your help
Paul.

True, I forgot that one. Has client-side response (=quick) and good control
over syntax. However it can't handle leap-years correctly!

Hans Kesting
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top