Sourav
Sourav

Reputation: 17530

jQuery validator to allow only basic characters

I want to allow basic characters A-Z, a-z,0-9, and basic special characters ~``!@#$%^&*()_+-=[]{};'\:"|,./<>? availalbe on a standard english keyboard to be only typed in a text area.
Looking for help !

Upvotes: 4

Views: 5017

Answers (1)

user748472
user748472

Reputation: 96

Sample:

    $('#text_area_id').keyup(function() {
        $(this).val($(this).val().replace(/[^A-Za-z0-9~`!@#$%^&*()_+-=\[\]{};'\\:"|,.\/<>?]/g,''))
    });

Upvotes: 8

Related Questions