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 -

how to prompt save As Box in Excel Interlop c# MVC 4 -

xslt 1.0 - How to access or retrieve mets content of an item from another item? -