473,394 Members | 1,840 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

best-practice form checking

I've constructed this form so that if Javascript is disaabled it will
show a typical <input type="submit"> button, BUT using the <noscript>
tag. Why is this a problem and what's a viable solution? i'm not sure
of the best way to do this so help is very much appreciated; snide,
smartass, unhelpful comments are useless. Please keep them to
yourself.
Jul 20 '05 #1
12 2506
cruiserweight wrote:
I've constructed this form so that if Javascript is disaabled it
will show a typical <input type="submit"> button, BUT using the
<noscript> tag. Why is this a problem and what's a viable solution?
The question is why you've done this. Why is a submit button only
available in no-js situations?
snide, smartass, unhelpful comments are useless. Please keep them
to yourself.

Best not to cop an attitude, especially before you've gotten any help.

--
Brian (remove ".invalid" to email me)

Jul 20 '05 #2
ba*****@yahoo.com (cruiserweight) wrote:
I've constructed this form so that if Javascript is disaabled it will
show a typical <input type="submit"> button, BUT using the <noscript>
tag.
What happens for users who do have JavaScript enabled? Do they get a
submit button at all?

In what way does it benefit some users _not_ to have an instantly
recognisable submit button?
Why is this a problem and what's a viable solution?
<noscript> is a blunt instrument. What if the user's browser supports
JavaScript but doesn't support all the individual parts that need to
be used to do whatever it is that you're doing?
i'm not sure
of the best way to do this so help is very much appreciated;


Write the form in HTML with a server side script that handles the
submission fully (including any checking that needs to be done).

Then add JavaScript on top of that to perform client side checking
(the time saved will benefit those who have JS enabled). This

JavaScript should be triggered via the onsubmit event handler of the
form (or equivalent event listener methods), not via the onclick event
handler of a particular button, etc.

This JavaScript should also be written so that the browser falls back
to submitting the form to the server in cases where the JavaScript can
not be processed - it should only ever not submit the form if a
definite error is detected in the data.

Technical questions on JS would be better directed to
comp.lang.javascript

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net> <http://steve.pugh.net/>
Jul 20 '05 #3
ba*****@yahoo.com (cruiserweight) wrote:
I've constructed this form so that if Javascript is disaabled it will
show a typical <input type="submit"> button, BUT using the <noscript>
tag. Why is this a problem and what's a viable solution? i'm not sure
of the best way to do this so help is very much appreciated; snide,
smartass, unhelpful comments are useless.
Is it being a smartass, and therefore useless, to bring to your
attention the fact that only a psychic can help you if you keep the
trouble-causing code a secret?
Please keep them to
yourself.


I'm so profoundly sorry for having wasted your time, but I couldn't
resist. May we now have *your* apologies for having wasted *our* time
by asking for help without providing relevant information?

--
Harlan Messinger
Remove the first dot from my e-mail address.
Veuillez ôter le premier point de mon adresse de courriel.
Jul 20 '05 #4
Harlan Messinger <hm*******************@comcast.net> wrote in message news:<7e********************************@4ax.com>. ..
ba*****@yahoo.com (cruiserweight) wrote:
I've constructed this form so that if Javascript is disaabled it will
show a typical <input type="submit"> button, BUT using the <noscript>
tag. Why is this a problem and what's a viable solution? i'm not sure
of the best way to do this so help is very much appreciated; snide,
smartass, unhelpful comments are useless.


Is it being a smartass, and therefore useless, to bring to your
attention the fact that only a psychic can help you if you keep the
trouble-causing code a secret?
Please keep them to
yourself.


I'm so profoundly sorry for having wasted your time, but I couldn't
resist. May we now have *your* apologies for having wasted *our* time
by asking for help without providing relevant information?

Point well-taken. Apologies all around. The form is at
http://www.veiyotonle.com/printablem...enu=printables. I put a
regular submit button inside noscript tags, and then used javascript
to writeln the code for the javascript button. fields are checked in
javascript (if enabled) and on the server. I've read in these groups
recently, i forget where, that this is not a very good way to do
things. I was to find a better way. Again, sorry for the a-hole
comments.
Jul 20 '05 #5
"cruiserweight" <ba*****@yahoo.com> a écrit dans le message de
news:18**************************@posting.google.c om
I put a
regular submit button inside noscript tags, and then used javascript
to writeln the code for the javascript button. fields are checked in
javascript (if enabled) and on the server.


Err, why don't use the onSubmit event ? It works perfectly for non enabled
javascript ua as for enabled ones !

Please see :
http://devedge.netscape.com/library/...s.html#1121163

Jul 20 '05 #6
"Pierre Goiffon" <pg******@nowhere.invalid> wrote:
"cruiserweight" <ba*****@yahoo.com> a écrit dans le message de
news:18**************************@posting.google. com
I put a
regular submit button inside noscript tags, and then used javascript
to writeln the code for the javascript button. fields are checked in
javascript (if enabled) and on the server.
Err, why don't use the onSubmit event ?


The onsubmit attribute has nothing to do with whether a button is
drawn via Javascript or directly with HTML.
It works perfectly for non enabled
javascript ua as for enabled ones !
Assuming we *are* talking about onsubmit, Javascript certainly is
required for onsubmit to have any effect.

Please see :
http://devedge.netscape.com/library/...s.html#1121163


....where it says, "Executes JavaScript code when a submit event
occurs; that is, when a user submits a form." In other words,
Javascript has to be enabled for it to do anything.

--
Harlan Messinger
Remove the first dot from my e-mail address.
Veuillez ôter le premier point de mon adresse de courriel.
Jul 20 '05 #7
cruiserweight wrote:
I've constructed this form so that if Javascript is disaabled
it will show a typical <input type="submit"> button, BUT using
the <noscript> tag.
regular submit button inside noscript tags, and then used
javascript to writeln the code for the javascript button. fields
are checked in javascript (if enabled) and on the server.


Too complicated, and too prone to failure. Create a form using only
html, forget completely about js. Create whatever validation you need
on the server. When the form works perfectly without js, add a js
validation routine, and attach it to the form's onsubmit handler. Have
the routine return false if there's an error.

http://www.xs4all.nl/~sbpoley/webmatters/formval.html

--
Brian (remove ".invalid" to email me)

Jul 20 '05 #8
"Harlan Messinger" <hm*******************@comcast.net> a écrit dans le
message de news:ho********************************@4ax.com
Err, why don't use the onSubmit event ?


The onsubmit attribute has nothing to do with whether a button is
drawn via Javascript or directly with HTML.


Well I wrote my post a little to fast. As I understand it, but it's not
perfectly clear, it seems Cruiserweight is using writeln to had JavaScript
checks for his form. If this is it, it could be replaced by a function
called in the onSubmit event. In fact I was answering that because
unfortunately JavaScript validation that blocks non-enabled Javascript ua is
very common. Just what I guessed reading Cruiserweight.

By the way Cruiserweight, maybe you should explain exactly what is the
difference between the normal html submit button and what is written via JS
? Is it just Javascript validation, or is there another things ?

Jul 20 '05 #9
Oops forgot to say...

"Harlan Messinger" <hm*******************@comcast.net> a écrit dans le
message de news:ho********************************@4ax.com
Err, why don't use the onSubmit event ?


Javascript has to be enabled for it to do anything.


Yes exactly, but Cruiserweight said there are a client side checking via
JavaScript, plus a server side one :
fields are checked in
javascript (if enabled) and on the server.


Jul 20 '05 #10
ba*****@yahoo.com (cruiserweight) wrote:

Point well-taken. Apologies all around. The form is at
http://www.veiyotonle.com/printablem...enu=printables. I put a
regular submit button inside noscript tags, and then used javascript
to writeln the code for the javascript button. fields are checked in
javascript (if enabled) and on the server. I've read in these groups
recently, i forget where, that this is not a very good way to do
things.
I gave one possible reason in my earlier post. Another is that your
way uses more code than the alternative.
I was to find a better way.


Change:
if ( good2go > 0) {
document.printform.submit();
return false;
}

to:
if ( good2go > 0) { return true; }

Change:
<form name="printform" method="post" action="print.html?menu=other">
to:
<form name="printform" method="post" action="print.html?menu=other"
onclick="return validate();">

Change:
<noscript><p class="body"><input type="submit" value="Print Selected"
name="Print Selected" /></p></noscript>
<script type="text/javascript"><!--
document.writeln ("<div><a href=\"#\" onClick=\"return validate();\"
class=\"button\">Print Selected</a></div>");
// --></script>

to:
<p class="body"><input type="submit" value="Print Selected"
name="Print Selected" /></p>

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net> <http://steve.pugh.net/>
Jul 20 '05 #11
Brian <us*****@julietremblay.com.invalid> wrote in message news:<40******@news-1.oit.umass.edu>...
cruiserweight wrote:
I've constructed this form so that if Javascript is disaabled it
will show a typical <input type="submit"> button, BUT using the
<noscript> tag. Why is this a problem and what's a viable solution?


The question is why you've done this. Why is a submit button only
available in no-js situations?
snide, smartass, unhelpful comments are useless. Please keep them
to yourself.

Best not to cop an attitude, especially before you've gotten any help.


absolutely right.
Jul 20 '05 #12
Steve Pugh <st***@pugh.net> wrote in message news:<u2********************************@4ax.com>. ..
ba*****@yahoo.com (cruiserweight) wrote:
I've constructed this form so that if Javascript is disaabled it will
show a typical <input type="submit"> button, BUT using the <noscript>
tag.


What happens for users who do have JavaScript enabled? Do they get a
submit button at all?

In what way does it benefit some users _not_ to have an instantly
recognisable submit button?


I believe this is the correct question. It benefits no one for 'some
users _not_ to have an instantly recognisable submit button'.

However, I'd really like to get away from, or at least explore,
options to the standard UI available through html. Overindulgent?
Perhaps a little. In this case, though, I will rework it to use the
onsubmit event handler as suggested and go with the admittedly
unnecessary javascript button.
Jul 20 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Roman Suzi | last post by:
;-) Just type into google "best programming language" and press (I am lucky) Sincerely yours, Roman Suzi -- rnd@onego.ru =\= My AI powered by GNU/Linux RedHat 7.3
15
by: John J | last post by:
I've written the following code into a class to search for and display the results of all races entered (The complete code is in a previous thread). I wish to amend the code so as to display the...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
20
by: hagai26 | last post by:
I am looking for the best and efficient way to replace the first word in a str, like this: "aa to become" -> "/aa/ to become" I know I can use spilt and than join them but I can also use regular...
3
by: Irene | last post by:
Hi all, I have set up a simple VB program (and later on an ASP interface) to manage an Athletics database. I'm using Access 2000. To simplify, I have the Athlets, the Competitions and the...
5
by: l.woods | last post by:
I want your recommendation on which ASP.NET Shopping Cart software I should buy? Best code Best documentation Best support (if needed. I will buying source code, if possible) TIA, Larry...
10
by: jojobar | last post by:
Hello, I am trying to use vs.net 2005 to migrate a project originally in vs.net 2003. I started with creation of a "web site", and then created folders for each component of the site. I read...
24
by: Earl | last post by:
I have all of my data operations in a separate library, so I'm looking for what might be termed "best practices" on a return type from those classes. For example, let's say I send an update from...
9
by: raylopez99 | last post by:
What's the best way of implementing a multi-node tree in C++? What I'm trying to do is traverse a tree of possible chess moves given an intial position (at the root of the tree). Since every...
11
by: ankitmathur | last post by:
Hi, I'm trying to overcome a situation whereby I have to search through 4-5 columns and produce the results with an order by according to the values matched in these columns. Example: My...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.