简体   繁体   English

在ember.js中输入一个必填字段

[英]make an input field required in ember.js

I know there is a way in plain html to require the field have some kind of value. 我知道纯HTML中有一种方法要求字段具有某种价值。 I believe it's 'input required'. 我相信这是“需要输入”的。 However, I'm not sure how to accomplish this in ember using handlebars. 但是,我不确定如何在使用手柄的余烬中实现此目的。 I've tried this but it was unsuccessful: 我已经尝试过了,但是没有成功:

{{input required value=tax class="form-control" placeholder="State Tax"}}

Thanks in advance. 提前致谢。

In ember input helpers you always have to give values to attributes. 在余烬输入助手中,您始终必须为属性赋予值。 The shourtcuts like <input disabled required value="..."/> in html without value are not allowed in handlebars. <input disabled required value="..."/>在handbars中使用类似html的<input disabled required value="..."/>没有值的快捷方式。 Instead you have to write {{input disabled=true required=true value="..."/> 相反,您必须编写{{input disabled=true required=true value="..."/>

See ember twiddle with your example: https://ember-twiddle.com/b073b4551065e8884056de55fe0c9800?openFiles=templates.application.hbs%2C 请参阅示例中的余烬捻转: https ://ember-twiddle.com/b073b4551065e8884056de55fe0c9800?openFiles = templates.application.hbs%2C

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM