You must Sign In to post a response.
  • Category: ASP.NET

    Remove special character from textbox

    i have many textbox in web page i want when i fill these text box than each textbox string should be checked and if they find any special character inside any textbox than replace it and return string without special char.
    it should be done in a single function for all text control which reside that page. and value should be without special character how to do this asp.net2.0 with c#
  • #417812
    you better go for javascript validation for special charcters.

    you can validate with regular expression with 2 lines of code.

    refer this resorce:-

    http://www.dotnetspider.com/resources/30892-Regular-Expression.aspx

    Gomathi Nayagam

    Please Rate my answer if it has helpful to you

  • #417813
    there is one simple thing instead of Removing Special characters and displaying string..

    simple use ascii codes to restrict Special Characters by Javascript...

  • #417825
    hi,

    use the code like this


    foreach(TextBox t in from.Control)
    {
    string strval = t.Text.ToString();
    if(strval.Contain("@"))
    {
    strVal = strVal.Repalce("@","");
    }
    } else if()



    like this you can search for any speacil character in the string..

    Thanks & Regards
    Anil Kumar Pandey
    Microsoft MVP, DNS MVM

  • #417838
    use javascript to replace those character..
    DNS MVM and .Net Guru
    Team Lead at CirrusCloud Systems
    Bhubaneswar,Odisha
    Thanks and Regards,
    Abhay Kumar Raut


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.