I have a textbox on a web form that I have the follow java code to enable a button only when the tilde key is entered. The problem I have is I cannot enter the \ or the ] keys without causing an error in the code logic. Here is the java code if (/^[a-zA-Z0-9- `!@#$%^&*()_+-={}|:"'?>|\[]*$/.test(str) == false) {. My second question is there a way to do this in the code behind?
Thanks in advance,
Kevin

ramya bharathRank #3,780 · 391 reputationPosted Apr 16, 2015, 9:46 AM EDT
ramya bharathRank #3,780 · 391 reputationPosted Apr 16, 2015, 8:57 AM EDT
For matching special characters u can also use \ W representation
you can also regular expression validator to perform the same operation
In server code if you want to handle u can call server side code on change events but this is unnecessary as enabling a button is a simple step which doesn't need a server call
Kevin Gilmore5 reputationPosted Apr 16, 2015, 9:37 AM EDT
Thanks
Kevin Gilmore5 reputationPosted Apr 16, 2015, 9:56 AM EDT
Thanks,