on 05-16-2006 11:06 PM
I have 3 input fields in my htmlb:form.
When the user presses the save button, this is what I do:
<htmlb:button id = "bg1" onClientClick = "chkformelements();"
onClick = "buttonPressed" >
In my javascript function I am reading the value of each field and raising alert accordingly (if they are balnk). Problem is: even when there is an alert scenario, my onclick server event still gets fired and does what I am trying to control.
How can I control (only fire) my onclick event depending on the outcome of onclientclick event maintained by js function?
Please help.
Thanks,
Partho
Hi,
You can control the firing of onclick event by using following code:
<htmlb:button id = "bg1"
onClientClick = "var val = 'no'; val = chkformelements();if(val == 'no'){htmlbevent.cancelSubmit=true;} if(val == 'yes'){htmlbevent.verify = true;}"
onClick = "buttonPressed" >
In the function chkformelements() return 'no' if validation fails and 'yes' otherwise. htmlbevent will control the firing of onClick.
I hope it helps.
Regards,
Rohit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.