Results 1 to 3 of 3
Aug 29, 2009, 04:44 #1
Why onclick doesn't work on submit button ?
Sorry it's a long time I programmed in Js, I come back to it now for my hobby site. I added a submit button with an onclick event and an alert message to say it doesn't work yet, but if I push the button, it isn't taken into account and the form is submitted to the cgi.
What's wrong ?
<input id="saveForm" class="button_text" type="submit" name="submit" value="Submit" onclick="alert('Sorry, it's not working yet!');return false;" >
Aug 29, 2009, 06:03 #2
- Join Date
- Jun 2009
- Ottawa, Ontario, Canada
- 0 Post(s)
- 0 Thread(s)
Somewhere in your JS you will need something like:
document.forms[X].onsubmit = validateBeforeSubmit;
where "X" indicates the form where the submit button is located and "validateBeforeSubmit" is a function you create.
If validateBeforeSubmit returns "true" then the submit function will be treated normally. If it returns "false" it won't.
That should do it...
Aug 29, 2009, 10:13 #3
Thanks but finally I found it, I didn't escape the "'"