如果设置了 paper-input 的只读属性,则 iron-form 中的验证将停止工作

validation inside iron-form stops working if readonly attribute of paper-input is set

我有铁形式和纸质输入类型='text',具有值绑定、必需属性和错误消息属性。

<form is="iron-form" id="form" method="post" action="/form/handler">
   <paper-input type="text" label="[[part.label]]" value="[[part.value]]" name="[[part.key]]" required error-message="Invalid input!"></paper-input>
</form>

验证工作正常,我看到错误消息,但是如果我将只读属性设置为我的纸张输入验证停止工作。

<form is="iron-form" id="form" method="post" action="/form/handler">
   <paper-input type="text" readonly label="[[part.label]]" value="[[part.value]]" name="[[part.key]]" required error-message="Invalid input!"></paper-input>
</form>

从逻辑上讲,这是一个错误,因为仍然设置了必需的属性,但没有进行验证。

即使使用只读属性,我仍然希望验证能够正常工作。该怎么做?

[编辑] 这是设计使然:HTML 5 Spec

Constraint validation: If the readonly attribute is specified on an input element, the element is barred from constraint validation.


[原创] 好像是原生问题(或者非功能性),这个也会失败:

<!DOCTYPE html>
<html>
<body>

<form>
  First name:<br>
  <input type="text" required readonly name="firstname">
  <br>
  Last name:<br>
  <input type="text" required name="lastname">
  <input type="submit">
</form>

<p>Note that the form itself is not visible.</p>

<p>Also note that the default width of a text input field is 20 characters.</p>

</body>
</html>