Solved

Safari having a spat with disable on submit code on website

Posted on 2013-02-02
4
252 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 6

Accepted Solution

by:
nickinthooz earned 250 total points
ID: 38847438
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 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 150 total points
ID: 38847507
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
ID: 38865972
Thanks - both seemed to do the trick although the "true" (in quotes) seemed the more efficient fix.
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 38866051
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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

756 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