I currently have a form with a disabled submit input. In firefox 4.0, if you press enter nothing happens (which is what I want).
In Chrome (11) or IE 7, it will try to submit the page.
Is there some Jquery that will make Chrome & IE behave like Firefox in this example?
I’ve created a test page for people – http://jsfiddle.net/tEsEU/1/
Here is the output html
<!DOCTYPE html>
<html lang="en-CA">
<head>
<title>Test</title>
</head>
<body>
<div class="page">
<div id="header">
<div id="title">
<h1>My App</h1>
</div>
<div id="logindisplay">
</div>
<div id="menucontainer">
<ul id="menu">
</ul>
</div>
</div>
<div id="main">
<div>
<form action="/Home/ChangePeoPerm" method="post">
<label for="userName" class="visibleFalse">asdfsdf</label>
<input type="text" name="userName" id="userName" value="d" />
<input type="submit" name="btnAddUser" id="btnAddUser" value=">>" disabled="disabled" />
</form></div>
<div id="footer">
</div>
</div>
</div>
</body>
</html>
Here is my mvc View
<div>
@using (Html.BeginForm("ChangePeoPerm", "Home"))
{
<label for="userName" class="visibleFalse">asdfsdf</label>
<input type="text" name="userName" id="userName" value="d" />
<input type="submit" name="btnAddUser" id="btnAddUser" value=">>" disabled="disabled" />
}
</div>
It looks like a bug in Chrome. The proposed solution is to use javascript to subscribe to the
onsubmitevent of the form and if the button is disabled cancel the submission. Here’s how you could achieve this with jQuery: