How to prevent user from typing in text field without disabling the field?

前端 未结 11 1667
不思量自难忘°
不思量自难忘° 2021-01-31 06:58

I tried:

$(\'input\').keyup(function() {

   $(this).attr(\'val\', \'\');

});

but it removes the entered text slightly after a letter is enter

11条回答
  •  无人及你
    2021-01-31 07:42

    Markup

    
    

    Script

    function preventInput(evnt) {
    //Checked In IE9,Chrome,FireFox
    if (evnt.which != 9) evnt.preventDefault();}
    

提交回复
热议问题