Override html5 validation

前端 未结 5 1795
野趣味
野趣味 2020-12-18 04:08

I\'m working on a simple login form, with two fields:

5条回答
  •  误落风尘
    2020-12-18 04:52

    This answer is incorrect. Please see willydee's answer.

    Simple, just add the novalidate property to any element you don't want the browser to validate, like so:

    
      
      
      
    
    

    Since you wish to only cancel validation when JavaScript is available, add it with JavaScript (using jQuery for simplified example)

    $('input[novalidate]').attr('novalidate', 'novalidate');
    

提交回复
热议问题