473,491 Members | 2,205 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 2281
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
2898
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
11376
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
2047
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
2522
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
5567
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
3137
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
2342
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
2055
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
6230
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
7115
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
7154
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
7360
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...
0
5451
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4881
isladogs
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...
0
3086
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3076
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1392
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 ...
0
280
bsmnconsultancy
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...

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.