This is a migrated thread and some comments may be shown as answers.

Block characters in filter fields

2 Answers 64 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Anzar
Top achievements
Rank 2
Anzar asked on 20 Sep 2012, 06:05 AM
Hi,
I have  to block some characters(%,!) when entering filter characters on the filter text box.

Thanks & Regards
Anzar.M

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 20 Sep 2012, 06:24 AM
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.
0
Anzar
Top achievements
Rank 2
answered on 20 Sep 2012, 06:28 AM
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
Tags
Grid
Asked by
Anzar
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Anzar
Top achievements
Rank 2
Share this question
or