HTML required readonly input in form

后端 未结 13 2119
执笔经年
执笔经年 2020-12-13 08:36

I\'m making a form. And on one input tag is an OnClick event handler, which is opening a popup, where you can choose some stuff, and then it autofi

13条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-13 09:20

    I have the same problem, and finally I use this solution (with jQuery):

    form.find(':input[required][readonly]').filter(function(){ return this.value === '';})
    

    In addition to the form.checkValidity(), I test the length of the above search somehow this way:

    let fcnt = $(form)
        .find(':input[required][readonly]')
        .filter(function() { return this.value === '';})
        .length;
    
    if (form.checkValidity() && !fcnt) {
       form.submit();
    }
    

提交回复
热议问题