Forum Moderators: open

Message Too Old, No Replies

Different behaviour in IE and FF

         

ncbugeye

9:33 pm on Jun 16, 2007 (gmt 0)

10+ Year Member



I have this application that needs some client-side verification of fields. The idea is that if any of the fields are wrong or missing it should put up an alert() and then return to the page, but if there are no errors, it submits. It works correctly under IE but in FF it puts up the error but then submits the page anyway.

The following drastically cut down fragment shows the behavior. Notice that there is no submit button or call to submit() in this example, but is submits anyway when the button is pressed.

Ideas?

<html>
<head>
<title>Order test</title>
<script type="text/javascript">
function vfy() {
alert(document.forms[0].elements[0].value);
}
</script>
</head>
<body>
<h1>Test</h1>
<form action="any.pl" method="post">
Name:<input name="Name" size="40"><button onclick="vfy();">Process order</button>
</form>
</body>
</html>

geofflee

11:30 am on Jun 17, 2007 (gmt 0)

10+ Year Member



The HTML <button> tag has a "type" attribute.

This is a normal button:
<button type="button"></button>

This is a submit button:
<button type="submit"></button>

Apparently, Internet Explorer and Firefox do not agree on the same default value for the "type" attribute.

-Geoffrey Lee

ncbugeye

1:42 pm on Jun 17, 2007 (gmt 0)

10+ Year Member



Thank you SO MUCH. I knew it had to be a simple dumb omission on my part, but I just couldn't see it for looking. I got close to banging my head against the wall on this one.

Interesting the two browsers have different defaults in this case.

Thanks again.