onsubmit() with Safari

J

JM Rosengard

Hi,
It seems that unlike other browsers, Safari will submit a form even
when the onsubmit event handler returns false. e.g. <form
onsubmit="return false" ...>

Is there a workaround to prevent the form being submitted?

Thanks,
JM
 
R

RobG

JM said:
Hi,
It seems that unlike other browsers, Safari will submit a form even
when the onsubmit event handler returns false. e.g. <form
onsubmit="return false" ...>

Is there a workaround to prevent the form being submitted?

First ya gotta prove that what you claim actually happens. For me in
Safari 1.0.3 the following form does not submit:


<script type="text/javascript">

function doSubmit(f){
alert('the onsubmit fired');
return false;
}
</script>
<form action="" onsubmit="return doSubmit(this);">
<input type="text" value="Change me and submit...">
<input type="submit">
</form>


But maybe you are submitting the form or trying to cancel submit some
other way?
 
J

JM Rosengard

Hi,
There are several reports on the web of this happening with Safari but
maybe this has been changed recently?
From my web server's log, the problem occurs at least for:
Safari/412.5
Safari/125.12
Safari/312.3.1

The version numbers mentioned are the one appearing in the user agent
field of HTTP requests.

Thanks

The code I am referring to is similar to Rob's.

Thanks
 

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

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top