JS define on screen is not working 

JS define on screen is not working 

  

Hi,

I have define following JS on Screen in order to restrict user to key in unwanted characters, I have also defined the class on text box. However, this is not working for me.

I can't see JS when I try to find on view page source. Please correct me I am doing anything wrong.

Thanks,

Sachin

Solution

@Sachin,

Try this , i tested it and is working fine.


$(document).ready(function(){
    $('.number').keypress(function(){
        alert('Pressed');
    });
});


Regards

-PJ-

Solution

Thanks PJ... works well.

SyntaxEditor Code Snippet

$(document).ready(function(){
    $('.Number').keypress(function(event){
        debugger;
        var keycode = event.which;
        if(!(keycode == 43 || keycode == 42 || keycode == 33)){
            event.preventDefault();
        }   
    });
});

@Sachin,

Did you try the above solution i posted? It is working David also confirmed this.


Regards

-PJ-

Pramod Jain wrote:

@Sachin,

Did you try the above solution i posted? It is working David also confirmed this.


Regards

-PJ-

Thanks PJ, It's worked for me.

Sachin


@Sachin,

Thanks and be alive in community.

Regards

-PJ-