Solved

Safari having a spat with disable on submit code on website

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

911 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

27 Experts available now in Live!

Get 1:1 Help Now