|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Complex CompareValidator ValidationsHi,
I have a datagrid with two ASP:TextBox TemplateColumns in which the user will enter MM/DD/YYYY dates. In one column, the date is not allowed to be more than 7 days into the future; and in the other column, the date must be less than or equal to today's date. We would like this to be client side validation. Is it possible to handle these types of comparisons with ASP:CompareValidator? Or any other validator? Thanks, John Yes, the CompareValidator with Type=Date works.
To set 7 days in the future: CompareValidator1.ValueToCompare = DateTime.Today.AddDays(7).ToShortDateString() To set today: CompareValidator2.ValueToCompare = DateTime.Today.ToShortDateString() Additionally, add a CompareValidator to confirm that the text is actually a valid date format so an entry like 99/99/9999 is considered invalid. The ValueToCompare feature only works against valid dates so the second validator is necessary. CompareValidator with Type=Date and Operator=DataTypeCheck. Even though this will provide client-side validation, you should ALWAYS setup server side validation because the validators only provide client-side validation on IE and IE/Mac and javascript can be turned off. (My Professional Validation And More has validators that support many more browsers.) Its very easy to get server side validation. In the Click post back event method, test Page.IsValid is true before saving. --- Peter Blum www.PeterBlum.com Email: PLB***@PeterBlum.com Creator of "Professional Validation And More" at http://www.peterblum.com/vam/home.aspx Show quoteHide quote "John Walker" <JohnWal***@discussions.microsoft.com> wrote in message news:D771D106-990D-42B4-BBC2-B73E12C33C12@microsoft.com... > Hi, > I have a datagrid with two ASP:TextBox TemplateColumns in which the user > will enter MM/DD/YYYY dates. In one column, the date is not allowed to be > more than 7 days into the future; and in the other column, the date must > be > less than or equal to today's date. We would like this to be client side > validation. Is it possible to handle these types of comparisons with > ASP:CompareValidator? Or any other validator? > > Thanks, > John Peter,
This works great! Thanks! John Show quoteHide quote "Peter Blum" wrote: > Yes, the CompareValidator with Type=Date works. > To set 7 days in the future: > CompareValidator1.ValueToCompare = > DateTime.Today.AddDays(7).ToShortDateString() > To set today: > CompareValidator2.ValueToCompare = DateTime.Today.ToShortDateString() > > Additionally, add a CompareValidator to confirm that the text is actually a > valid date format so an entry like 99/99/9999 is considered invalid. The > ValueToCompare feature only works against valid dates so the second > validator is necessary. > CompareValidator with Type=Date and Operator=DataTypeCheck. > > Even though this will provide client-side validation, you should ALWAYS > setup server side validation because the validators only provide client-side > validation on IE and IE/Mac and javascript can be turned off. (My > Professional Validation And More has validators that support many more > browsers.) > > Its very easy to get server side validation. In the Click post back event > method, test Page.IsValid is true before saving. > > --- Peter Blum > www.PeterBlum.com > Email: PLB***@PeterBlum.com > Creator of "Professional Validation And More" at > http://www.peterblum.com/vam/home.aspx > > "John Walker" <JohnWal***@discussions.microsoft.com> wrote in message > news:D771D106-990D-42B4-BBC2-B73E12C33C12@microsoft.com... > > Hi, > > I have a datagrid with two ASP:TextBox TemplateColumns in which the user > > will enter MM/DD/YYYY dates. In one column, the date is not allowed to be > > more than 7 days into the future; and in the other column, the date must > > be > > less than or equal to today's date. We would like this to be client side > > validation. Is it possible to handle these types of comparisons with > > ASP:CompareValidator? Or any other validator? > > > > Thanks, > > John > > >
How to update a Image control?
Infragistics Ultra Web Grid Updating Problem Listbox Webcontrol SelectedIndexChanged Event not working Who is the true Asp.Net MVP here? Trying hard to implement globalisation. Strange error message(urgent help needeed) load event doesn't fire unless init event is present Finding the leftmost pixel in a piece of text when using GDI+ DataGrid and Paging. How to view properties of control inside table Client Side Calculation involving controls in datagrid template co |
|||||||||||||||||||||||