troubleshooting Question

Need to check for ASP.NET Validation result client side (before hits the server)...

Avatar of Cognize
Cognize asked on
JavaScriptASP.NETAJAX
3 Comments1 Solution387 ViewsLast Modified:
Hi,

I've noticed a bug where a user is able to click the submit button on a form twice before the page returns, which is having an unwanted affect. Why the page is allowed to submit twice (cutting off the processing of the previous request - I'm not sure).

I've seen similar posts, which suggest disabling the button with javascript. This is what I'm doing for now essentially, but with a timer to re-enable the button if the form doesn't validate client side. This is a less than perfect solution though.

The reason I have to disable and re-enable client side, is that if the form validation fails client side, I have to re-enable the button so the user can edit input and re-submit using the code below.

What id prefer is a way of checking validation results in code, on the client side, so I can disable on the initial click, and then re-enable if the form validation fails, so the user can have another go.

Does anyone know how to test for this?
function disableButton() {
 
                                        var buttonDiv = document.getElementById('regBtnDiv');
                                        buttonDiv.style.visibility = "hidden";
                                        buttonDiv.style.height = "0px";
 
                                        var msgDiv = document.getElementById('validatingMessage');
                                        msgDiv.style.visibility = "visible";
                                        msgDiv.style.height = "20px";
                                        
                                        setTimeout('showButton()', 2000);
                                    }
 
                                    function showButton() {
 
                                        var buttonDiv = document.getElementById('regBtnDiv');
                                        buttonDiv.style.visibility = "visible";
                                        buttonDiv.style.height = "auto";
 
                                        var msgDiv = document.getElementById('validatingMessage');
                                        msgDiv.style.visibility = "hidden";
                                        msgDiv.style.height = "0px";
                                    }
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros