asp.net - On Key Down Restrict the user to enter Some Special Characters -


i want restrict user in toolbar search not allowing him/her using special characters ('/','>','<','|').please me out.

$("#tblfundcomp").bind("keydown",function(e)  {   if(e.keycode >=48 && e.keycode <=57 )    {      return false;    }   else    {      return true;    } });  

i have placed piece of code after before search function. not work

if want allow special characters entered in input field of search toolbar can use dataevents of searchoptions defined using type:'keypress' or type:'keydown'. follows call jquery.bind , jquery.unbind corresponding input field. code fragment allows digits following

searchoptions: {     dataevents: [         {             type: 'keypress', // keydown             fn: function(e) {                 // console.log('keypress');                 if(e.keycode >=48 && e.keycode <=57) {                     // allow digits                     return true;                 } else {                     // disallow key                     return false;                 }             }         }     ] } 

in live demo not able enter digits in search field 'name'.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -