سؤال

Hey, I am using this plugin to prevent characters from being entered into an input field.

http://www.itgroup.com.ph/alphanumeric/

It works very well, except that it does not disallow all. characters it is supposed to. I am using the following code:

$('#dialog-box #label').alphanumeric({allow:"., ?!&+-_/\\"});

It is supposed to only allow alphanumeric + the given characters e.g. ? ! or &. While it works for e.g. in preventing $ or ), you can still write characters like those ~°^§ it guess I guess it has something to do with me having a german keyboard and the CharCodes being different? I added all the characters to the plugin to be forbidden, but it does not help.

Some, like ° and § can be disallowed by using the function twice and the second time using the ichars with them. But others like ~ and ^ will still not be deleted.

Can anyone help me?

Thanks in advance.

// Update I used the console and found out, that ^ and ~ do not appear when typed. They seem to not be recognized by charCode. Is there any workaround?

هل كانت مفيدة؟

المحلول

A little late, but I found this. http://blog.treyhunner.com/2010/10/replacement-for-jquery-alphanumeric.html Maybe a useful alternative.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top