2

I have successfully build Jq GRid with Asp.Net with all the required features except the one to "Avoid Spl Characters in Tool Bar Search" . I tried to find the ID of the toolbar but with no success. Can any one tell me how can we use Regular Expression like stuff to deny entering of Some Spl Char like "/,:,',\" and few others. I dont want the user to enter those char in tool bar search.

hkv
  • 163
  • 1
  • 6
  • 15

1 Answers1

2

The Toolbar Searching has beforeSearch event handler which can return false to stop searching. One can use this for validation of the data.

If you do want to know how to find the searching field manually you should understand following. The ids of the fields in the searching toolbar will be constructed from the "gs_" prefix and the name of the column. You should also understand, that the toolbar is not a part of the <table> element. jqGrid build some dives over the <table> element. For example if your <table> has id="list", the name of the div which contain the searching toolbar as a child (not a direct child) are #gview_list.

UPDATED: I created an example for you. Try to type and text in the search field for names which is not 5 characters long and you receive an error message and the searching will be stopped.

Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Hi Oleg, I tried beforeSearch. bu its not triggering itself.I tried something like this – hkv Nov 15 '10 at 13:01
  • beforeSearch:function(){alert('1');if($('gs_Name').value=='?')return false else return true. In this code alert itself is not getting fired up. Can u please suggest me where i have done wrong. If possible can u paste me some sample to achieve the same. Thanks in Advance – hkv Nov 15 '10 at 13:03
  • Hi Oleg, Thanks a ton you have solved my issue and using your sample code i will complete my pending tasks. Thank you – hkv Nov 15 '10 at 14:55
  • @ Oleg, I have one more Question to you its like now my organisation wants me to restrict the user in key down itself for which i have done the following. But i get the error as "object not supported" this is my code $("#tblFundComp").bind("keydown",function(e) { if(e.keyCode >=48 && e.keyCode <=57 ) { return false; } else { return true; } }); Can u Please tell me where i have made the mistake – hkv Nov 16 '10 at 06:38
  • 1
    @hitesh: In general your code look like OK, but importand is also where you place it. Mostly the error "object not supported" means, that you use an object before you define some it's properties, which means for example, that at the moment jQuery JavaScript is not yet loaded. You should post more full code. The context is very important. Morover I don't quite understand what do you mean under "restrict the user in key down itself". Probably it would be better if you open new question and describe all what you need whithout problem with the place which you have inside of "comments". – Oleg Nov 16 '10 at 09:07
  • @ Oleg : I have pasted my Question and its URL is http://stackoverflow.com/questions/4192768/on-key-down-restrict-the-user-to-enter-some-special-characters. Please have a look at that this – hkv Nov 16 '10 at 09:41
  • @Oleg I want regular expression validation in add form of JQgrid. How can I do that ? – Bhavik Ambani Jul 26 '12 at 10:16