禁用带有非法单词的表单提交 [英] Disable form submit with illegal words

查看:66
本文介绍了禁用带有非法单词的表单提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个脚本,可以禁用表单上的提交按钮,或者在文本框中存在非法字词或字符时阻止提交表单。这可以防止垃圾邮件机器人通过我的网站联系我功能向我发送链接。这是我需要保护的表单:

[HTML]

< form id =" FormName"行动= QUOT; thehandler.cgi"方法= QUOT;交" name =" FormName">


< p>名称:/ Naam:< input type =" text"命名= QUOT;名称"大小= QUOT; 24英寸; />< / p>

< p>电子邮件:/ E-pos:< input type =" text"名称= QUOT;电子邮件"大小= QUOT; 24英寸; />< / p>

< p>消息:/ Boodskap:< br />

< textarea name =" message"行= QUOT; 4英寸cols =" 30">< / textarea>< / p>

< p>< input type =" submit"命名= [提交/ stuur"值= [提交/ Stuur" />< / p>

< / form>

[/ HTML]


消息textarea是应该检查的字段。删除了不必要的文本。

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="thehandler.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.

推荐答案

它不会阻止垃圾邮件机器人。有人可以禁用JavaScript。


无论如何,执行此操作的方法是以正常的验证方式:
It won''t prevent spam bots. Someone could just disable JavaScript.

Anyhow, the way to do this is in the normal validation way:
展开 | 选择 | Wrap | 行号


大家好,你的意思是非法的话,你可以像Coder先生建议的那样验证表格,或者你想要更具体。 TextArea的onKeyPress事件编写自己的逻辑,这样用户只能输入没有特殊符号和数字的字符。只有这一点可以完成,当用户在那里输入文本时,你无法检查他输入的内容是否有意义。如果有任何疑问,我会尽力帮助你


问候

Ramanan Kalirajan
Hi, what did you mean by Illegal words, You can validate the form as Mr. Coder suggested or if you want to be more specific. onKeyPress event for TextArea write your own logic, so that the user can only enter character without special symbol and numbers. This alone can be done u can''t check what he entered is meaningful or not while the user enters the text over there. If any doubts post it back I will try to help you out

Regards
Ramanan Kalirajan



你的意思是非法的话,你可以像Coder先生建议的那样验证表格,或者你想要更具体。 TextArea的onKeyPress事件编写自己的逻辑,这样用户只能输入没有特殊符号和数字的字符。只有这一点可以完成,当用户在那里输入文本时,你无法检查他输入的内容是否有意义。如果有任何疑问,我会尽力帮助你


问候

Ramanan Kalirajan
Hi, what did you mean by Illegal words, You can validate the form as Mr. Coder suggested or if you want to be more specific. onKeyPress event for TextArea write your own logic, so that the user can only enter character without special symbol and numbers. This alone can be done u can''t check what he entered is meaningful or not while the user enters the text over there. If any doubts post it back I will try to help you out

Regards
Ramanan Kalirajan



非法的单词/字符将在JS中指定,并在表单提交之前进行验证。如何告诉JS在文本区域中检查它?这就是我的问题所在。字符是:"<>?[]"我们的想法是阻止他们向我发送我没有时间访问的其他网站的链接。 (这些消息大约每次下载120 k,每天都有很多)


感谢您的帮助

The illegal words/characters are to be specified in JS and be validated prior to form submit. How do I tell JS to check for it in the text area? That is where my problem is. The characters are: "<>?[]" The idea is to prevent them from sending me links to other sites i don''t have time to visit. (these messages are about 120 k each to download and every day there are a lot of them)

Thank you for the help


这篇关于禁用带有非法单词的表单提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆