如何在jQuery或JavaScript的帮助下从字符串中删除特殊字符 [英] How to remove special character from a string with the help of jquery or javascript
本文介绍了如何在jQuery或JavaScript的帮助下从字符串中删除特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用jquery或javascript
How to remove special character from a string with the help of jquery or javascript
推荐答案
而不是删除特殊符号,我建议不要使用特殊符号
Hi,
instead of remove special symbols i recomend that dont allow special symbols
using javascript u can do this otherwise use ajax
javscript code--
<script language="javascript">
function onlyNumber(evt) {
if (!(evt.keyCode >= 48 && evt.keyCode <= 57)
return false;
</script>
and in page load event write following line
txtNumber.Attributes["onkeypress"] = "return onlyNumber(event);";
Hope this Help u
Best luck
您可以使用正则表达式来做到这一点.
var output = stringToReplace.replace(/[^\w\s\n],
'''')之类的东西.
查看转义JavaScript中的正则表达式字符 [
You could use regular expressions to do this.
Something likevar output = stringToReplace.replace(/[^\w\s\n],
'''').
Check out Escaping regular expression characters in JavaScript[^].
这篇关于如何在jQuery或JavaScript的帮助下从字符串中删除特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文