Hi guys, I am using a MaskedEdit extender for a datetime entry. However, in case of invalid input of date and time, how am be able to validate it through the use of Ajax and validation will occur when the user clicks on the submit button. Any idean that can help me or a site that discusses this kind of issue.
Why can’t you use just regularexpressionvalidator?
SirGe, I reccomend the jQuery route, it takes care of much the grunt work for you. A quick search of “jQuery Validation” will set you in the right direction. Much easier then you think.
Here is an tutorial example:
And, here is the Date Time Regular Expressions:
Good Luck
I probably should have mentioned, you should do both client-side and server-side when doing validation. jQuery for the client, and asp:validators for the server. Custom validators, if the others don’t fill the need.
Validation of dates can much easier be achieved using a CompareValidator:
<asp:CompareValidator ID=“CompareValidator1” runat=“server” ErrorMessage=“CompareValidator” ControlToValidate=“TextBox1” Operator=“DataTypeCheck” Type=“Date” />
Or if the date should be in a certain period, use a rangevalidator, which also raises an error when an invalid date is entered:
<asp:RangeValidator ID=“RangeValidator1” runat=“server” ErrorMessage=“RangeValidator” ControlToValidate=“TextBox1” Type=“Date” MinimumValue=“2000/01/01” MaximumValue=“2099/01/01” />
The asp validators work both client and server side, ni need for jQuery…
Yes, validators work client and server side only if you check Page.IsValid.
no need for jQuery, but jQuery is definitely a lot more elegant that asp validators