Has anyone added code to scroll to validation messages?

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
ZLA
Commodore (COMO)
Commodore (COMO)
Posts: 496
Joined: Fri Mar 13, 2009 2:55 pm

Has anyone added code to scroll to validation messages?

Post by ZLA » Wed May 20, 2009 11:21 am

I've added validator error messages for some of my custom fields which display on the Product page. When the product information (description, etc) is long, you don't see the validation message unless you scroll down. I'd like the error message to be more visible by having the page scroll down to it.

I've done this in a different project by adding an internal page link and appending the internal page link to the querystring. Has anyone done something like this already?

Alternatively, is there a way to display an AJAX modal popup window stating there are errors and the user may need to scroll down to see them?

Thanks.

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Has anyone added code to scroll to validation messages?

Post by mazhar » Thu May 21, 2009 6:28 am

ASP.NET page also contains a client side flag about the validity of page called Page_IsValid. Read following topic about details
http://msdn.microsoft.com/en-us/library/aa479045.aspx
You can wrap your ValidationSummary in a div with some anchor and then put some javascript upon some suitable location to jump to that anchor location depending upon this flag.

ZLA
Commodore (COMO)
Commodore (COMO)
Posts: 496
Joined: Fri Mar 13, 2009 2:55 pm

Re: Has anyone added code to scroll to validation messages?

Post by ZLA » Thu May 21, 2009 6:50 am

Thanks Mazhar. I wasn't aware of the client side flag. I can just add a client side script block at the bottom of the page that looks for that flag and the div. If both are present, redirect to it.

Separate from that, I'll be posting my validation code sometime today. I've got slightly improved version of the required field validation customization to show. But more importantly, I have a regular expression validation customization to show.

Regards,

ZLA

Post Reply