Solved

Safari having a spat with disable on submit code on website

Posted on 2013-02-02
4
249 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
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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 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…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

813 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

17 Experts available now in Live!

Get 1:1 Help Now