Hi, say we have the code below on a button:
<input type="button" class="btn" value="Continue " onclick="if
(myform.p_name. value=='') alert('You must enter a name for the folder');
else { this.disabled=t rue; submit();}">
Not all the validation can be performed client-side so the button may be
pressed and then server validation is performed - this may result in a
request to the user to hit the back button and correct some data
entered.
Now this isn't the best UI design, I know. But nonetheless we have to
stick with this for a qhile and I have noticed a difference in the way
Fireforx and IE handles the button disbaling. On IE, when you go back to
the page, the button is enabled again whereas in Firefox it remains grey
and disabled.
Can anyone suggest a way in which we can automatically re-enable the
button when the user presses the back button? Is there some code we can
put into the onload perhaps which will go through all buttons on the
form and enable them?
Appreciate your suggestions.
--
jeremy 26 21299
Jeremy wrote: <input type="button" class="btn" value="Continue " onclick="if (myform.p_name. value=='') alert('You must enter a name for the folder'); else { this.disabled=t rue; submit();}">
This is nonsense, see below.
Not all the validation can be performed client-side so the button may be pressed and then server validation is performed - this may result in a request to the user to hit the back button and correct some data entered.
And what would be wrong with this? Your application should be able to
handle that anyway.
Now this isn't the best UI design, I know. But nonetheless we have to stick with this for a qhile
Not at all.
and I have noticed a difference in the way Fireforx and IE handles the button disbaling. On IE, when you go back to the page, the button is enabled again whereas in Firefox it remains grey and disabled.
Can anyone suggest a way in which we can automatically re-enable the button when the user presses the back button? Is there some code we can put into the onload perhaps which will go through all buttons on the form and enable them?
No. You /have to/ reconsider your design instead. Especially:
1. Use a submit button, i.e. input[type="submit"], input[type="image"],
or button[type="submit"] (where the latter two are not backwards
compatible). This way users will be able to submit without client-side
script support.
2. Use the `onsubmit' event handler of the `form' element, and do the form
validation there, by calling a validation function instead of this
badly maintainable spaghetti code. Return `true' to the handler if you
want the form to be submitted, `false' otherwise. Numerous examples of
this have been posted here before. Please do a minimum of research
before you post here; it is a _news_group.
3. Use server-side sessions, so you can detect server-side if data has been
received from that client before, unless the server-side session timed
out, or was actively ended.
PointedEars
In article <12************ ****@PointedEar s.de>, Thomas 'PointedEars'
Lahn says... No. You /have to/ reconsider your design instead. Especially:
1. Use a submit button, i.e. input[type="submit"], input[type="image"], or button[type="submit"] (where the latter two are not backwards compatible). This way users will be able to submit without client-side script support.
2. Use the `onsubmit' event handler of the `form' element, and do the form validation there, by calling a validation function instead of this badly maintainable spaghetti code. Return `true' to the handler if you want the form to be submitted, `false' otherwise. Numerous examples of this have been posted here before. Please do a minimum of research before you post here; it is a _news_group.
3. Use server-side sessions, so you can detect server-side if data has been received from that client before, unless the server-side session timed out, or was actively ended.
Thanks. I don't doubt the validity of the points you are making here. I
however am in the best position to be able to determine whether or not
it is feasible at this stage to rewrite the way we handle certain bits
of coding. The application is available to a closed group of users over
whom we can exercise some control over what browsers are used.
In the short term, as a hack fix (I make no bones about this), it would
meet my needs to be able to simply re-enable the button when the page is
redisplayed after a user has pressed the back button. I think from your
statement above " No. You /have to/ reconsider your design instead. " I
am right in understanding that you are saying that it is not a case of
it not being desirable but a case of it not being possible - is that so?
Thanks again
--
jeremy
While I'm of the opinion that you could rewrite your validation the way
he suggested in the time it takes to post here, I'll be nice and answer
the question as asked ;)
Your best bet is to enable the buttons by name, one after another, in a
simple onload script. If you're doing something quick and dirty, you
might as well. It will work, its just not the prettiest code or the
most efficient way to do it. You do need to name your button and form,
though, or referencing will be a real pain.
Something along the lines of:
<head>
<script>
function mewantbuttons() {
theform.continu ebtn.disabled = false;
theform.otherbt ns.disabled = false;
}
</script>
</head>
<body onload="mewantb uttons()">
<form NAME="theform">
<input NAME="continueb tn" type="button" class="btn" value="Continue "
onclick="if
(myform.p_name. value=='') alert('You must enter a name for the
folder');
else { this.disabled=t rue; submit();}">
</form>
----
That said, I agree with Thomas's assessment. It will take you very
little time to write your javascript cleanly to act onsubmit.
Also, I tend to avoid javascript validation myself. If the threat is
that they'd have to re-enter data, I have the server validation give
them their data back pre-filled in the form. The back button won't
always give them their data back, so you shouldn't rely on it.
Jeremy wrote: [...] Thomas 'PointedEars' Lahn says... No. You /have to/ reconsider your design instead. Especially:
1. Use a submit button, i.e. input[type="submit"], input[type="image"], or button[type="submit"] (where the latter two are not backwards compatible). This way users will be able to submit without client-side script support.
2. Use the `onsubmit' event handler of the `form' element, and do the form validation there, by calling a validation function instead of this badly maintainable spaghetti code. Return `true' to the handler if you want the form to be submitted, `false' otherwise. Numerous examples of this have been posted here before. Please do a minimum of research before you post here; it is a _news_group.
3. Use server-side sessions, so you can detect server-side if data has been received from that client before, unless the server-side session timed out, or was actively ended. Thanks. I don't doubt the validity of the points you are making here. I however am in the best position to be able to determine whether or not it is feasible at this stage to rewrite the way we handle certain bits of coding. The application is available to a closed group of users over whom we can exercise some control over what browsers are used.
It is not a question of the browser that is used. That the form would be
usable without client-side script support is a positive side effect of
proper design (using `onsubmit' instead of `onclick'). And who knows --
one member of your closed group might want to access the application with a
mobile device you do not know about yet that does not support client-side
scripting, or simply has it disabled because of some unnerving "features"
"provided" by a number of incompetent people on the Web.
[...] I think from your statement above " No. You /have to/ reconsider your design instead. " I am right in understanding that you are saying that it is not a case of it not being desirable but a case of it not being possible - is that so?
Exactly.
PointedEars
Thomas 'PointedEars' Lahn said the following on 3/24/2006 12:26 PM: Jeremy wrote:
[...] Thomas 'PointedEars' Lahn says... No. You /have to/ reconsider your design instead. Especially:
1. Use a submit button, i.e. input[type="submit"], input[type="image"], or button[type="submit"] (where the latter two are not backwards compatible). This way users will be able to submit without client-side script support.
2. Use the `onsubmit' event handler of the `form' element, and do the form validation there, by calling a validation function instead of this badly maintainable spaghetti code. Return `true' to the handler if you want the form to be submitted, `false' otherwise. Numerous examples of this have been posted here before. Please do a minimum of research before you post here; it is a _news_group.
3. Use server-side sessions, so you can detect server-side if data has been received from that client before, unless the server-side session timed out, or was actively ended. Thanks. I don't doubt the validity of the points you are making here. I however am in the best position to be able to determine whether or not it is feasible at this stage to rewrite the way we handle certain bits of coding. The application is available to a closed group of users over whom we can exercise some control over what browsers are used.
It is not a question of the browser that is used.
Do you continue to fail to comprehend what an IntrAnet is? Obviously you
do and keep trying to force everything into a square box when it's round.
That the form would be usable without client-side script support is a positive side effect of proper design (using `onsubmit' instead of `onclick'). And who knows -- one member of your closed group might want to access the application with a mobile device you do not know about yet that does not support client-side scripting, or simply has it disabled because of some unnerving "features" "provided" by a number of incompetent people on the Web.
Can you still not read plain English Thomas?
Let me quote it back to you, you quoted it yourself:
<quote>
The application is available to a closed group of users over
whom we can exercise some control over what browsers are used.
</quote> [...] I think from your statement above " No. You /have to/ reconsider your design instead. " I am right in understanding that you are saying that it is not a case of it not being desirable but a case of it not being possible - is that so?
Exactly.
Exactly? Sure, Exactly Wrong.
--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Randy Webb wrote: Thomas 'PointedEars' Lahn said the following on 3/24/2006 12:26 PM: Jeremy wrote: Thanks. I don't doubt the validity of the points you are making here. I however am in the best position to be able to determine whether or not it is feasible at this stage to rewrite the way we handle certain bits of coding. The application is available to a closed group of users over whom we can exercise some control over what browsers are used.
It is not a question of the browser that is used.
Do you continue to fail to comprehend what an IntrAnet is?
You have yet to understand what an Intranet is, and that it does
not restrict its users to one user agent, especially not in the
mid-term. Probably you have never used an Intranet before. I have.
PointedEars
*Turns the fire hoses on.* Would be nice to do without the flames...
Randy, the problem here isn't that he doesn't understand, it's that he
has a different philosophical approach. Thomas is looking at it from
the perspective of the future and the unknown. Jeremy can't know if his
closed environment is about to have the doors opened to mobile devices,
or perhaps someone with a visual impairment gets hired to the team, and
the javascript doesn't work for his screen reader, or any other such
scenario. He also can't know if someone on the team has circumvented
him and got permission from "upstairs" to connect his latest
nonstandard toy. If that happens, all this time he's spent developing
QnD solutions (now, and each subsequent time) is wasted. Taking this
opportunity to do it right also makes maintenance in the future much
faster and simple.
I agree with Thomas's thinking on this, just because you believe your
environment is controlled, doesn't mean it really is, or that it will
stay that way. It's called being a conscientious programmer.
Merennulli wrote: [...] <head> <script> function mewantbuttons() { theform.continu ebtn.disabled = false; theform.otherbt ns.disabled = false; } </script> </head> <body onload="mewantb uttons()"> <form NAME="theform"> <input NAME="continueb tn" type="button" class="btn" value="Continue " onclick="if (myform.p_name. value=='') alert('You must enter a name for the folder'); else { this.disabled=t rue; submit();}"> </form> [...]
Unfortunately(? ), your code (even if it was Valid) is not going to do what
it is intended to do. mewantbuttons() will not be called when the Back
feature is used because the `onload' code will not be called then. Not
even if you use Cache-Control in an attempt to prevent caching of the
resource (which is not recommended, though).
We discussed this before; there is no better solution than to drop the idea
of disabling the buttons completely, and to handle the problem on the
server.
Regards,
PointedEars
Thomas 'PointedEars' Lahn said the following on 3/24/2006 1:04 PM: Randy Webb wrote:
Thomas 'PointedEars' Lahn said the following on 3/24/2006 12:26 PM: Jeremy wrote: Thanks. I don't doubt the validity of the points you are making here. I however am in the best position to be able to determine whether or not it is feasible at this stage to rewrite the way we handle certain bits of coding. The application is available to a closed group of users over whom we can exercise some control over what browsers are used. It is not a question of the browser that is used. Do you continue to fail to comprehend what an IntrAnet is?
You have yet to understand what an Intranet is, and that it does not restrict its users to one user agent, especially not in the mid-term.
Thank you for my daily laugh today Thomas.
What is, or is not, allowed on an intranet can be *very* controlled and
in most environments it is. The fact that you fail to realize that is
indication of your lack of comprehension of what I wrote.
Probably you have never used an Intranet before.
Really? I help manage an Intranet that is larger than your feeble mind
could possibly comprehend. And you know what? I can tell you *precisely*
what UA's are on it and what is and is not allowed on it.
I have.
Logging on at school to do your homework does not count.
--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: bart plessers |
last post by:
Hello,
Somewhere in my code I have
<input TYPE="button" NAME="btnFirst" VALUE="<<" OnClick="GetFile('1')"
DISABLED>
I changed the layout of the INPUT with a stylesheet to
INPUT {
color: #FFFFFF;
|
by: John Smith |
last post by:
As it is now apparently illegal in the UK to produce a website which
is inaccessible to the disabled, which includes the
JavaScript-disabled and images-disabled, am I right in thinking that
the only ASP.NET postback capable control which is now of any use is
the Button control? The LinkButton is clearly no good as it uses
JavaScript and the ImageButton doesn't work in Mozilla with scripting
and images turned off. Am I missing something or...
|
by: xazos79 |
last post by:
Hi All,
I've come across the problem of not being able to re-enable a radio
button with javascript if its initial state has been disabled in the
Page_Load() method of the code behind.
Might i add that it behaves fine in Firefox, but IE is unable to
re-enable the radio button. IE is fine if the radio button starts in an
enabled state.
|
by: Phil_Cam |
last post by:
Hello All
On a webpage I have a standard paypal image button for purchases. I am
trying to set it up so that it only shows up or is endabled when text
is entered into a textbox and a button is pressed. To do this I set the
type to hidden and changed the type of the button using javascipt to
image. This works perfectly in Modilla's Firefox but in IE it says
there is a scipt error.
Here is the javascipt
|
by: Joey |
last post by:
Hello,
In my C# asp.net 2.0 application, I have a webform with a button server
control on it. The webform, like most others in the site, subscribes to
a master page. I have determined that the button always renders with an
id of "ct100_ContentPlaceHolder1_btnContinue" in both the IE and
Firefox browsers.
I created the following javascript code segment to disable it when the
page loads. I have reasons for not wanting to do this with...
| |
by: bay_dar |
last post by:
Hi, I have an internal ASP.NET application that I'm are using to send
e-mails out based on a single milepost or milepost range entered.
I'm trying to do two things when a user clicks on the submit button
to submit a form that contains one or two Mileposts:
1) If a Milepost range larger than 5 miles is entered, I would
like to
pop up a confirmation box to confirm the range.
|
by: Plater |
last post by:
I am up to my neck in javascript troubles these days.
Ok so I have a button on my webpage with an onclick event.
In the onclick event I do the following:
Disable the button (so they can't click it again)
Change the text on the button (the value)
Perform an xmlHttpRequest.send() (I think it's asynchronous since I do this: http.onreadystatechange = handleSendTestEmailResponse;)
And in my statechanger function, when I decide it's done...
|
by: arggg |
last post by:
I created a submit form that calls a javascript:AjAX Command that will call the data and submit it without have the page refresh. This works perfect in Firefox however in IE and Opera when the submit button is pressed it just disables the button and does not submit the data. Any idea?
<script type="text/javascript" src="<?=$config->getKey('Site_URL')."js/AJAX.js"?>"></script>
<form name="EditUser" method="post" accept="text/plain"...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |