从输入表单中删除HTML TAG输入 [英] Remove HTML TAG Inputs from input Form

查看:90
本文介绍了从输入表单中删除HTML TAG输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,基本上当我输入时,它不会允许它。
我想添加更多像< > / \ etc我该怎么做?

Ok basically when I type , it won't allow it. I want to add more like < > / \ etc how do I do it?

$("#in1").keypress(function (evt) {
    if (String.fromCharCode(evt.which) == ",")
        return false;
});


<input type="text" id="in1">

可在此处查看演示。 http://jsfiddle.net/QshDd/38/

Can see the demo here. http://jsfiddle.net/QshDd/38/

推荐答案

如果你有一个不允许的字符列表,你可以这种方式禁止它们:

If you have a list of disallowed characters, you can forbid them in this fashion:

$("#in1").keypress(function (evt) {
    return [',', '<', '>', ].indexOf(String.fromCharCode(evt.which)) === -1;
});

这篇关于从输入表单中删除HTML TAG输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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