Forums

PopUp Javascript Validation Before Submit

dion 05 Apr, 2009
I'm trying to get user confirmation with popup windows (Yes/No/Cancel).
If user click yes, then data sumited. If no, user returned to current form.
I put this on Form JavaScript:

function confirmAction() {
        return confirm("Do you really want this subscription?")
}


and this on Form HTML:

 <input value="Send" type="submit" onSubmit="return confirmAction()"/>

But it did'nt work, when i click submit, data submitted without calling my custom javascript.

Can anyone help please??
GreyHead 05 Apr, 2009
Hi dion,

That code looks Ok to me - is the form on-line so I can take a look?

Bob
dion 05 Apr, 2009
This is my form.
I PM u my online version.
Thank you before.
GreyHead 06 Apr, 2009
Hi dion,

It works if you make the submit button action onclick instead of onsubmit. (I think that perhaps you can only use onsubmit in the form tag ??)

Bob
dion 06 Apr, 2009
it works with onclick🙂

(I think that perhaps you can only use onsubmit in the form tag ??)


Yes,after reading references, onsubmit only work with form object, not with button.
This topic is locked and no more replies can be posted.