Custom Regex Expression = $ ~ # № \ ; < > % / -


i need create regular expression match following characters on input:

= $ ~ # № \ ; < > % / 

i don't have idea how combine or setup regex case.

i have this

$('input').bind('keypress', function (event) { var regex = new regexp(???); var key = string.fromcharcode(!event.charcode ? event.which : event.charcode); if (!regex.test(key)) {    event.preventdefault();    return false; } }); 

need prevent symbols typing

try this:

var pattern = /^[=$~#№\\;<>%/]*$/ 

and if want letters , numbers try this:

var pattern = /^[a-za-z0-9=$~#№\\;<>%/]*$/ 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -