Prevent form submission on enter key

后端 未结 15 1287
夕颜
夕颜 2020-12-05 06:24

How can I prevent the enter key from submitting the form in angular?

Is there a way to catch the 13 key and disable it or set the form as invalid unless submitting f

15条回答
  •  不思量自难忘°
    2020-12-05 06:55

    angular.element(document).ready(function () {
        angular.element(window).keydown(function () {
            if(event.keyCode == 13) {
                      event.preventDefault();
                      return false;
            }
        });
    });
    

    Try with this in angularjs controller

提交回复
热议问题