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

Check whats being entered into the filter textbox

1 Answer 42 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Joslyn
Top achievements
Rank 1
Joslyn asked on 10 Dec 2013, 01:57 PM
Hi
On filtering is to possible to check whats being entered into the filter textbox? For one column i want to get whar the user enters if its any special characters then remove it.how to achieve this?

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 10 Dec 2013, 02:06 PM
Hi Joslyn,

Below is a sample code snippet that I tried ,on the TextBox OnBlur event I'm checking the characters being entered and clearing other characters.

ASPX:
<telerik:GridBoundColumn UniqueName="ShipCity" DataField="ShipCity" CurrentFilterFunction="Contains"
 ShowFilterIcon="false" AutoPostBackOnFilter="true" HeaderText="ShipCity"  />

C#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridFilteringItem)
    {
        GridFilteringItem filterItem = (GridFilteringItem)e.Item;
        (filterItem["ShipCity"].Controls[0] as TextBox).Attributes.Add("OnBlur", "CharacterCheck(this, event)");
    }
}

JS:
<script type="text/javascript">
    function CharacterCheck(text, e) {
        text.value = text.value.replace(/[^0-9a-zA-Z]/gi, '');
    }
</script>

Thanks,
Princy
Tags
Grid
Asked by
Joslyn
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or