javascript - Ember.js 2.7 - How to check validation on an input field? -


i'm pretty new ember.js , i'm having trouble how validation on input field.

here code template index.hbs:

<div class="jumbotron text-center">   <h1>coming soon</h1>    <br/><br/>    <p>don't miss our launch date, request invitation now.</p>    <div class="form-horizontal form-group form-group-lg row">     <div class="col-xs-10 col-xs-offset-1 col-sm-6 col-sm-offset-1 col-md-5 col-md-offset-2">       {{input type="email" value=model.email class="form-control" placeholder="please type e-mail address." autofocus="autofocus"}}     </div>     <div class="col-xs-10 col-xs-offset-1 col-sm-offset-0 col-sm-4 col-md-3">         <button disabled={{isdisabled}} {{action 'saveinvitation' model}} class="btn btn-primary btn-lg btn-block">request invitation</button>     </div>   </div>   {{#if responsemessage}}     <div class="alert alert-success">{{responsemessage}}</div>   {{/if}}   <br/><br/> </div> 

and here code controller index.js:

import ember 'ember';  export default ember.controller.extend({    headermessage: 'coming soon',   responsemessage: '',   email: '',    isvalid: ember.computed.match('email', /^.+@.+\..+$/),   isdisabled: ember.computed.not('isvalid'), }); 

the input field want validation email one. know how go validation replacing value="" field value="email", want know how can using value=model.email

this seems easy problem, can't find on docs particular issue.

as using input helper update model.email property when type in text field.

1.you dont need declare email property in controller.
2.isvalid computed property dependent key should model.email

import ember 'ember';  export default ember.controller.extend({    headermessage: 'coming soon',   responsemessage: '',    isvalid: ember.computed.match('model.email', /^.+@.+\..+$/),   isdisabled: ember.computed.not('isvalid'), }); 

Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -