Validation in ASPX

  • Thread starter Thread starter Paul King
  • Start date Start date
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
 
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
 
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.
 
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
 
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
 
Back
Top