SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
-
Aug 29, 2009, 05: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 ?
Code:<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, 07:03 #2
- Join Date
- Jun 2009
- Location
- Ottawa, Ontario, Canada
- Posts
- 120
- Mentioned
- 0 Post(s)
- Tagged
- 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...
floater
-
Aug 29, 2009, 11:13 #3
Thanks but finally I found it, I didn't escape the "'"
Bookmarks