Jump to content

Jquery help


usauae

Recommended Posts

4 minutes ago, usauae said:

How do I restrict a text box not to have special characters only. 
ex1: S@m is ok.

ex2: $&@ is not ok 

 

$('input').on('keypress', function (event) {
    var regex = new RegExp("^[a-zA-Z0-9]+$");
    var key = String.fromCharCode(!event.charCode ? event.which : event.charCode);
    if (!regex.test(key)) {
       event.preventDefault();
       return false;
    }
});
Link to comment
Share on other sites

11 minutes ago, Epic said:
$('input').on('keypress', function (event) {
    var regex = new RegExp("^[a-zA-Z0-9]+$");
    var key = String.fromCharCode(!event.charCode ? event.which : event.charCode);
    if (!regex.test(key)) {
       event.preventDefault();
       return false;
    }
});

Bro idi complete ga special characters block chestundi kada 

I should be able to enter s@m but not $@/\/\

Link to comment
Share on other sites

11 minutes ago, usauae said:

Bro idi complete ga special characters block chestundi kada 

I should be able to enter s@m but not $@/\/\

Oh in that case probably you can try this on submit 

string str = “$@/\/\”;
var regex = /^[^a-zA-Z0-9]+$/;

 var onlySpl = regex.test(str);

        if (onlySpl) 

// show notification

Link to comment
Share on other sites

8 minutes ago, Epic said:

Oh in that case probably you can try this on submit 

string str = “$@/\/\”;
var regex = /^[^a-zA-Z0-9]+$/;

 var onlySpl = regex.test(str);

        if (onlySpl) 

// show notification

brahmi%20kissing.gif
worked like a charm bro.

ila finger tips meeda yela vuntayi bro neeku ? 
naku 0 memory asalu.

Link to comment
Share on other sites

4 minutes ago, usauae said:

brahmi%20kissing.gif
worked like a charm bro.

ila finger tips meeda yela vuntayi bro neeku ? 
naku 0 memory asalu.

Google search 

n9s3w1.gif

  • Haha 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...