473,386 Members | 1,883 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,386 software developers and data experts.

submit button

How can I disable a submit button for a form if JS is disabled. In other
words, JS must be enabled to submit the form.

Thanks

Harvey

--

http://righttax/blog
Dec 1 '06 #1
11 2275
Harvey Waxman wrote:
How can I disable a submit button for a form if JS is disabled. In other
words, JS must be enabled to submit the form.
The submit button isn't your problem, if it was, the solution would be
trival. Write the button using javascript, say document.write() it.

But some (most?) browsers can submit a form without a submit button.
Some solutions:

1. Create the entire form using javascript

2. Create the form in HTML with display: none and then
change that to display:'' using script, e.g.:

<form id="formA" style="display: none;" >
<input type="text" value="formA">
...
</form>
<script type="text/javascript">
document.forms['formA'].style.display = '';
</script>
Assuming appropriate feature detection etc.
--
Rob

Dec 1 '06 #2
VK

Harvey Waxman wrote:
How can I disable a submit button for a form if JS is disabled. In other
words, JS must be enabled to submit the form.
<form ...>
....
<script type="text/javascript">
document.writeln('<input type="submit">');
</script>
<noscript>
<span style="color:red">Your message</span>
</noscript>
</form>

Dec 1 '06 #3
VK
Harvey Waxman wrote:
How can I disable a submit button for a form if JS is disabled. In other
words, JS must be enabled to submit the form.

<form ...>
...
<script type="text/javascript">
document.writeln('<input type="submit">');
</script>
<noscript>
<span style="color:red">Your message</span>
</noscript>
</form>
Though I'm considering more user friendly to show some general
hard-to-miss warning atop of it:
<http://groups.google.com/group/comp.infosystems.www.authoring.stylesheets/msg/2f90dbab58ed02a7>

Dec 1 '06 #4
I hope you're not doing this as a security measure, since it will be
possible to submit the form no matter *how* the submit button is
customized.

Dec 1 '06 #5
In article <11*********************@16g2000cwy.googlegroups.c om>,
"Joseph Taylor" <Jo******@gmail.comwrote:
I hope you're not doing this as a security measure, since it will be
possible to submit the form no matter *how* the submit button is
customized.
Thanks

It's more of a nuisance measure. If the form and the asp are in subdirectories
and paths are relative to the document wouldn't that directory be unknown to
the spammer making it impossible to send from anyplace else?

--
Dr. Harvey Waxman

http://righttax.org/blog
Dec 1 '06 #6
I'll work with that and see. Thanks for the suggestion

In article <11**********************@79g2000cws.googlegroups. com>,
"RobG" <rg***@iinet.net.auwrote:
Harvey Waxman wrote:
How can I disable a submit button for a form if JS is disabled. In other
words, JS must be enabled to submit the form.

The submit button isn't your problem, if it was, the solution would be
trival. Write the button using javascript, say document.write() it.

But some (most?) browsers can submit a form without a submit button.
Some solutions:

1. Create the entire form using javascript

2. Create the form in HTML with display: none and then
change that to display:'' using script, e.g.:

<form id="formA" style="display: none;" >
<input type="text" value="formA">
...
</form>
<script type="text/javascript">
document.forms['formA'].style.display = '';
</script>
Assuming appropriate feature detection etc
--
Harvey Waxman DMD

(remove thefrown to email)
http://righttax/blog
Dec 1 '06 #7
In article <11*********************@16g2000cwy.googlegroups.c om>,
"Joseph Taylor" <Jo******@gmail.comwrote:
I hope you're not doing this as a security measure, since it will be
possible to submit the form no matter *how* the submit button is
customized.
I just realized that the full path is available in the address bar :-

--
Harvey Waxman DMD
73 Wright Lane
Wickford, RI 02852
(remove thefrown to email)
http://righttax/blog
Dec 1 '06 #8
VK
Joseph Taylor wrote:
I hope you're not doing this as a security measure, since it will be
possible to submit the form no matter *how* the submit button is
customized.
Doing what? Please provide a minimum quote of what are you replying to.

In relevance to <noscriptblocks they do not prevent users from
reverse engineering the obtained page and say still submit the form;
all what <noscriptblock can do is to alert users that some important
functionality is missing (say data update over ajaxoids is not
possible) and that they should not use the page in the state it is
right now. Will user follow this warning or will she attempt to hack
your source is out of your control. This way an additional server-side
check is highly suggested is any case.

Dec 1 '06 #9
In article <11**********************@j72g2000cwa.googlegroups .com>,
"VK" <sc**********@yahoo.comwrote:
Joseph Taylor wrote:
I hope you're not doing this as a security measure, since it will be
possible to submit the form no matter *how* the submit button is
customized.

Doing what? Please provide a minimum quote of what are you replying to.

In relevance to <noscriptblocks they do not prevent users from
reverse engineering the obtained page and say still submit the form;
all what <noscriptblock can do is to alert users that some important
functionality is missing (say data update over ajaxoids is not
possible) and that they should not use the page in the state it is
right now. Will user follow this warning or will she attempt to hack
your source is out of your control. This way an additional server-side
check is highly suggested is any case.
Sorry, just tried to save some space.

I understand that this is a losing battle, that determined hackers can continue
to offer me tons of viagra etc.

Still, I'm trying to learn. What I'd like to do is to have an asp validation
for one field that will reject a submission but I haven't been able to get it
to work. The form never gets submitted so I obviously have copied or placed
the code incorrectly. Here is the asp code
<%
Validated_Form = true
IF st <"RI" THEN
Validated_Form = false
END IF

IF NOT Validated_Form THEN
%>
<HTML>
<BODY>
Error. Click back in your browser and activate Javascript.
</HTML>
</BODY>

<%
ELSE
Dim name,address,city,st,email,show,comments
name = Request.Form("name")
address = Request.Form("address")
city = Request.Form("city")
st = Request.Form("st")
email = Request.Form("email")
comments = Request.Form("comments")
show = Request.Form("show")
Dim ObjMail
Set ObjMail = Server.CreateObject("CDONTS.NewMail")
ObjMail.To = "xx***@xxx.xxx"
ObjMail.From = "xx***@xxx.xxx"
ObjMail.Subject = "Petition"
ObjMail.Body = "Name" & vbtab & name & vbcrlf&_
"Address" & vbtab & address & vbcrlf&_
"City" & vbtab & city & vbcrlf&_
"State" & vbtab & st & vbcrlf&_
"Email" & vbtab & email & vbcrlf&_
"Add Name?" & vbtab & show & vbcrlf&_
"Comments" & vbtab & comments
ObjMail.Send
Set ObjMail = Nothing
Response.Write"Thank You"
%>
<HTML>
<BODY>
<B>Thank you for filling out the form!</B>
<BR><BR>
</body></html>
<%
END IF
%>

Thanks

--
Harvey Waxman
remove spam to email
http://righttax.org/
Dec 1 '06 #10
VK

Harvey Waxman wrote:
I understand that this is a losing battle, that determined hackers can continue
to offer me tons of viagra etc.

Still, I'm trying to learn. What I'd like to do is to have an asp validation
for one field that will reject a submission but I haven't been able to get it
to work.
If you want to complicate spammers life a little bit and if you are OK
with rendering your form useless without script support, then you could
obfuscate action attribute:

function setFormAction() {
document.forms['MyForm'].action = realURL;
}
window.onload = setFormAction;
....
<form name="MyForm" action="go_away_nasty_spammer">
....

But of course it's all baby toys :-) A real automated spam protection
can be made only server-side by generating sessionID, verification
number and obfuscated picture with verification number. Then you send
both picture and sessionID to client, on submit finding the relevant
verification number by sessionID and checking it agains the user input.

JavaScript is not of big help here.

Dec 1 '06 #11
Understood, thanks

In article <11*********************@j72g2000cwa.googlegroups. com>,
"VK" <sc**********@yahoo.comwrote:
Harvey Waxman wrote:
I understand that this is a losing battle, that determined hackers can
continue
to offer me tons of viagra etc.

Still, I'm trying to learn. What I'd like to do is to have an asp
validation
for one field that will reject a submission but I haven't been able to get
it
to work.

If you want to complicate spammers life a little bit and if you are OK
with rendering your form useless without script support, then you could
obfuscate action attribute:

function setFormAction() {
document.forms['MyForm'].action = realURL;
}
window.onload = setFormAction;
...
<form name="MyForm" action="go_away_nasty_spammer">
...

But of course it's all baby toys :-) A real automated spam protection
can be made only server-side by generating sessionID, verification
number and obfuscated picture with verification number. Then you send
both picture and sessionID to client, on submit finding the relevant
verification number by sessionID and checking it agains the user input.

JavaScript is not of big help here.


--
Harvey Waxman
remove spam to email
http://righttax.org/
Dec 2 '06 #12

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

Similar topics

3
by: Matt | last post by:
I want to understand the difference between submit button and regular button: <input type="submit"> and <input type="button">. My understanding is that submit button will send the entire HTML form...
6
by: JSjones | last post by:
Hi all, I'm new to these boards and my javascript experience is fairly limited and basic so please bear with me. Anyway, on to the question and some background. I'm developing using ColdFusion...
1
by: reneecccwest | last post by:
Hello, I'd like to pass the "levelbtn" value when I click the filter button, but there are also other submit form buttons. I defined as "document.testform.submit();" in the javascript, but I...
15
by: JR | last post by:
Hi. I hope someone out there who is more versed with JavaScript than I can help me with the following annoying problem. Here's the problem. I have a form with the following layout: Column A...
4
by: Dmitry Korolyov [MVP] | last post by:
When we use btnSubmit.Attributes = "javascript: this.disabled=true;" to make the button disabled and prevent users from clicking it again while form data still posting, there is no longer...
3
by: Jeff | last post by:
I have a payment form with a submit button. A large percentage of users double-click the submit button thus submitting their payment information twice. I would like to use javascript to disable...
7
by: David T. Ashley | last post by:
Hi, For a web page, I want a SUBMIT button that commits the form data and a CANCEL button that goes to a different target (i.e. a different script). I haven't figured out how to do this,...
7
by: Bjorn Sagbakken | last post by:
Hello. There maybe an simple answer to this, but sometimes one get a strange blindness when working intensely on one single problem. I'm using ASP.NET 2003, building pages that include 3 user...
1
by: abcdriver | last post by:
Later edit: Too complex: The only thing I should know is: The submit button's NAME (and value) will only be sent if that particular button was used to submit the form, so you should be able to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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
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
jinu1996
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...

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.