<form>
<paper-input label="Name" name="name"></paper-input>
<paper-input label="Email" name="email" type="email" required></paper-input>
<paper-input label="Phone" name="phone" type="tel"></paper-input>
<paper-input label="Message" name="message" multiline></paper-input>
<input name="code" value="12345" hidden required>
</form>
<paper-fab icon="arrow-forward" on-tap="{{submit}}" style="float:right"></paper-fab>
当我使用常规输入时,例如隐藏的输入,我删除它正确地告诉我有效性为假。
submit:function(){
var form = this.shadowRoot.querySelector('form')
var isValid = form.checkValidity();
console.debug(isValid)
},
但如果纸张输入电子邮件留空checkValidity()
仍然注册为有效?
(https://github.com/Polymer/paper-input/issues/75)
2部分:
<polymer-element name="my-name" extends="input" attributes="value" noscript>
<template>
<paper-input label="Name" name="name" value="{{value}}"></paper-input>
</template>
</polymer-element>
<polymer-element name="my-email" extends="input" attributes="value" noscript>
<template>
<paper-input label="Email" name="email" value="{{value}}" type="email" required></paper-input>
</template>
</polymer-element>
<polymer-element name="my-phone" extends="input" attributes="value" noscript>
<template>
<paper-input label="Phone" name="phone" value="{{value}}" type="tel"></paper-input>
</template>
</polymer-element>
<polymer-element name="my-message" extends="input" attributes="value" noscript>
<template>
<paper-input label="Message" name="message" value="{{value}}" multiline></paper-input>
</template>
</polymer-element>
-
<form>
<input is="my-name">
<input is="my-email" type="email" required>
<input is="my-phone">
<input is="my-message">
<input name="code" value="12345" hidden required>
</form>
令人惊讶的是这有效:D 造型除外?它看起来很小,突然我有边框和东西?
答案 0 :(得分:2)
聚合物元素(扩展HTML输入元素的元素除外 - 纸质和核心元素输入元素仅嵌入HTML输入元素)不被识别为表单输入元素,不能参与表单验证。
另见paper-button with type="submit" within form doesn't submit?