Block characters in filter fields

3 posts, 0 answers
  1. Anzar
    Anzar avatar
    62 posts
    Member since:
    Sep 2012

    Posted 20 Sep 2012 Link to this post

    Hi,
    I have  to block some characters(%,!) when entering filter characters on the filter text box.

    Thanks & Regards
    Anzar.M
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 20 Sep 2012 Link to this post

    Hi,

    Try the following code to remove special characters while filtering.
    C#:
    protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
     if (e.Item is GridFilteringItem)
     {
       GridFilteringItem filterItem = (GridFilteringItem)e.Item;
       (filterItem["UniqueName"].Controls[0] as TextBox).Attributes.Add("onkeyup", "CharacterCheck(this, event)");
     }
    }
    JS:
    function CharacterCheck(text, e)
    {
      var regx, flg;
      regx = /[^0-9a-zA-Z'' ]/
      flg = regx.test(text.value);
      if (flg)
      {
        var val = text.value;
        val = val.substr(0, (val.length) - 1)
        text.value = val;
      }
    }

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Anzar
    Anzar avatar
    62 posts
    Member since:
    Sep 2012

    Posted 20 Sep 2012 Link to this post

    HI Shinu,

    I have to block this characters InvalidChars="&;`'\|*?~<>^()[]{}$&quot;". And also block  paste characters from clip board to that textbox.

    Thanks & Reagrds
    Anzar.M
Back to Top