ASPNet validation and Javascript

D

Dick W

I have a page that conatins some text boxes that need to be completed
before submission. I used requiredFieldValidators which work very
well.

User being what they are where quite happy, but they wanted an
Hourglass displayed when the page is submitted as they can't remember
whether they have clicked the button.

I found the following javascipt and vb souce that wires the submit
button to a client side javascript that displays the hourgalss and
submits the form, but this ignores the validation controls.

I've reverted to using server side validation to re-display the form
if the boxes are not completed, but this is far from ideal

Anyone any idea on how I can display an hourglass AND use the client
side validation controls, or suggest an alternative.

Form contains a submit button btnSubmit

Pageload code behind file:
btnSubmit.Attributes.Add("onClick", "return doit();")

javascript:

<script language="javascript">
function doit()
{
document.body.style.cursor='wait'
}
</script>

btnsubmit on-click code executes as normal after hourglass displayed

Thanks
 
H

Hans Kesting

Dick W said:
I have a page that conatins some text boxes that need to be completed
before submission. I used requiredFieldValidators which work very
well.
[snip]
Form contains a submit button btnSubmit

Pageload code behind file:
btnSubmit.Attributes.Add("onClick", "return doit();")

javascript:

<script language="javascript">
function doit()
{
document.body.style.cursor='wait'
}
</script>

btnsubmit on-click code executes as normal after hourglass displayed

Thanks

What if you use "doit();" instead of "return doit();" ? Asp.net adds it's own code
to that event handler but that now never gets reached, as you returned already.
As a remark: do not forget the ";" as it separates your code from the .net added code.

Hans Kesting
 
D

Dick W

Hans,

thanks for the quick response. Removing the return does trigger the
validation controls but, having set the Hourglass it stays like that.
Nearly there




*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top