Ristrict用户使用jquery在MVC中的文本中输入HTML标记 [英] Ristrict user to enter HTML tags in text in MVC using jquery
本文介绍了Ristrict用户使用jquery在MVC中的文本中输入HTML标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我有一个模态弹出窗口,其中有多个字段,如地址,城市。
i希望限制用户在该文本框中输入任何html标签。 />
喜欢
测试
Hi
I have one modal popup where there are multiple fields like address, city.
i want to restrict user to enter any html tags in that textbox.
like
test
推荐答案
JavaScript为您做到这一点。
看看这个: http:// www .c-sharpcorner.com / Blogs / 12995 / how-to-restrict-user-to-put-html-tag-into-textbox.aspx [ ^ ]
JavaScript does that for you.
Take a look at this: http://www.c-sharpcorner.com/Blogs/12995/how-to-restrict-user-to-put-html-tag-into-textbox.aspx[^]
function CheckForHtmlTag(){
var reg =/<(.|\n)*?>/g;
if (reg.test(
('' #myTextBox')。val())){
var ErrorText = 糟糕!不允许使用HTML。;
alert(' ErrorText');
}
}
('#myTextBox').val())) { var ErrorText = "Oops! HTML is not allowed."; alert('ErrorText'); } }
-KR
-KR
这篇关于Ristrict用户使用jquery在MVC中的文本中输入HTML标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文