Solved

Safari having a spat with disable on submit code on website

Posted on 2013-02-02
4
247 Views
Last Modified: 2013-02-07
It seems that Safari (often on an iPad) and in some rare cases other browsers will not contime when on a web Submit button this code is present to stop users clicking submit repeatedly:
onclick='this.value = "Please wait..."; this.disabled = true'

Open in new window


Is there another more compatible way of doing it?
0
Comment
Question by:kiwistag
  • 2
4 Comments
 
LVL 6

Accepted Solution

by:
nickinthooz earned 250 total points
Comment Utility
true needs to be wrapped in quotes

<input type="submit"  onclick='this.value = "Please wait..."; this.disabled = "true"'>

Open in new window

Here it is in jsfiddle

http://jsfiddle.net/eZhAH/12/
0
 
LVL 82

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 150 total points
Comment Utility
This was kind of interesting.  It would get locked on the "Please wait" if it submitted to itself.  If I made two copies of the file and had them submitting back and forth, it never got stuck.  But I did use a different method, an 'onsubmit' which gets called when you click on a submit button.  'submit-onclick-test.html' and 'submit-onclick-test2.html' differ only in the filename in the action attribute.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title>submit onclick test</title>
<script type="text/javascript">
<!--
function check() {
x=document.getElementById("number");
x.value=x.value+1;
document.getElementById("submit").value = "Please wait...";
}
// -->
</script>
</head>
<body>
<h1>submit onclick test</h1>
<form action="submit-onclick-test2.html" method="get" onsubmit="return check();">
<input type="text" name="number" id="number" value="0" />
<input type="text" name="test" value="test" />
<input type="submit" name="submit" id="submit" value="Submit" />
</form>
</body>
</html>

Open in new window

0
 
LVL 6

Author Closing Comment

by:kiwistag
Comment Utility
Thanks - both seemed to do the trick although the "true" (in quotes) seemed the more efficient fix.
0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
It might be more efficient but I'm not sure it gets called if the user presses 'Enter' instead of clicking on the submit button.  I know the 'onsubmit' does.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now