473,856 Members | 1,380 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Disable form submit with illegal words

Jacotheron
44 New Member
I need a script that can disable the submit button on a form or prevent the form from being submitted when there is an illegal word or character in the text box. This should prevent a spam bot from sending links to me via my website's contact me function. Here is the form that I need to protect:
[HTML]
<form id="FormName" action="thehand ler.cgi" method="post" name="FormName" >

<p>Name: /Naam: <input type="text" name="name" size="24" /></p>
<p>Email: /E-pos: <input type="text" name="email" size="24" /></p>
<p>Message: /Boodskap:<br />
<textarea name="message" rows="4" cols="30"></textarea></p>
<p><input type="submit" name="Submit/stuur" value="Submit/Stuur" /></p>
</form>
[/HTML]

The message textarea is the field that should be checked. Unnecessary text were removed.
Aug 11 '08
11 2319
gits
5,390 Recognized Expert Moderator Expert
with the suggested regExp by acoder you could cut down the entire thing to the following simple function:

[HTML]<html>
<head>
<script type="text/javascript">
function check(node) {
var re = new RegExp('[<>\?\\[\\]]', 'g');
document.getEle mentById('mySub mit').disabled = re.test(node.va lue);
}
</script>
</head>
<form action="demo.ht ml">
<textarea onkeyup="check( this)">
</textarea>
<br/>
<input type="submit" value="submit" id="mySubmit"/>
</form>
</html>[/HTML]
kind regards
Aug 27 '08 #11
Jacotheron
44 New Member
with the suggested regExp by acoder you could cut down the entire thing to the following simple function:

[HTML]<html>
<head>
<script type="text/javascript">
function check(node) {
var re = new RegExp('[<>\?\\[\\]]', 'g');
document.getEle mentById('mySub mit').disabled = re.test(node.va lue);
}
</script>
</head>
<form action="demo.ht ml">
<textarea onkeyup="check( this)">
</textarea>
<br/>
<input type="submit" value="submit" id="mySubmit"/>
</form>
</html>[/HTML]
This form works now!

Thank You all for helping e solve this problem

Kind regards
Jacotheron
Aug 28 '08 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

4
9308
by: Stuart Perryman | last post by:
Hi, I have the following code which works just fine in IE6 but not in Firefox. It is an extract of several table rows each with an individual form. It is generated by php. <form action="MaintNotification.php?ReqID=5" method="post" name="frm5"> <tr align="left" bgcolor="#dddddd" class="text" onClick="submit()"
3
3174
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 the submit button once it's been clicked, yet still have the form submit. I can do this in ASP 2.0, however, ASP.Net seems to be adversely affected if you disable the submit button. Here's how I have it set up... The submit button is a...
4
4859
by: whyyyy | last post by:
USING IIS 5.1, and Windows XP pro, the following form works on my system, and I can use as many form elements as I wish, as long as all form elements have the same name: "words", in this example. Help -- why can`t I give each form element a different name? Any suggestions will be gratefully appreciated. Also,See example at very bottom of something that once worked on a remote server, but doesn't on IIS 5.1, windows xp pro
4
2741
by: kschneider | last post by:
Assume there's a form with it's action attribute all set to post to a URL, but without a submit control. Form submission is done via a link and I want to prevent the classic "double submit". Ignoring the server side of things, does anyone see any holes with the following script? It seems to work, but I'd appreciate other eyes on it. Maybe a try/catch/finally wrapper of some sort to be sure the link is re-enabled in the face of an...
0
9766
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,...
0
11066
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10391
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 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...
0
9536
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7099
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();...
0
5963
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4584
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
2
4177
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3203
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 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...

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.