asp.net如何过滤用户提交的信息?
如过滤掉用户提交的Textbox里面的非法信息。如过滤掉“法国”。谢谢!

解决方案 »

  1.   

    String Value = TextBox1.Text.Replace("法国","");
      

  2.   


    可以算是一种办法学习ing
      

  3.   

    String Value = TextBox1.Text.Replace("法国",""); 
    这样就可以
      

  4.   

    有没有什么比较好的办法检测用户提交的信息中是否含有某些字符,如果有的话拒绝提交。
    如检测Textbox1中是否有“法国”,如果有的话拒绝提交,没有的话正常提交。
      

  5.   


    可以写一个函数
    public share replaceword(string str)
    {
     str=str.replace("法国","");
    str+=str.replace("日本","");
    str+=str.replace("'","''");
    str+=str.replace(" ","");
    return str.Tostring();
    }
    String Value = replaceword(TextBox1.Text) 
      

  6.   

    function checkChinese() 

    var str=document.getElementById("txtTest").value; 
    var reg = /法国/; 
    if (reg.test(str)){ 
    alert("包含非法字符"); 
    return false

    else{ 
    return true

      

  7.   

    function pkfei(){
           if (document.form.askername.value.length==0){
           alert("请输入你的姓名!");
           document.form.askername.focus();
           return false;
           }
           var str=",./'[]{}`-=\~!@#$%^&*()_+|?><:法国";
           var errorChar
           errorChar = isCharsInBag(form.askername.value,str)
           if (errorChar != "" )
           {
                  alert('联系人姓名包函有非法字符,请重写!');
                  document.form.askername.focus();
                  return false;
           } 
    }
      

  8.   

    这是js吧,我对这里面的document.form理解不是很透,能不能稍稍指点一下。
      

  9.   

    if (Yue.IndexOf("寒") >= 0) { Yue = "十一月"; }
      

  10.   

    自己写一个HttpModule类,对Request的数据进行过滤
    如果只是单纯过滤TextBoxt1.Text,那么写一个StringFilter(ref string input){} 的方法即可。
    用正则表达式判断,并且读取过滤字符配置进行Replace
      

  11.   

    下面这个行吗?
    http://www.cnblogs.com/insus/articles/1407256.html
      

  12.   

    建立一个需要过滤的词组
    然后通过replace就可以