mercredi 26 avril 2017

How to use jquery-validation on emberjs properly?

I am trying to create a simple validation to require name (will add more validations later). The app an ember app, and we want to use jquery validation.

I am having trouble just to get a basic validation running. This is what I have:

//index.html
<script src="http://ift.tt/1oMJErh"></script>
<script src="http://ift.tt/2qfU6MO"></script>

... 
//body and such//
...

<script>
  $('#salesForm').validate();
</script>

</body>

Inside a component, say sales-form:

//app/components/sales-form/template.emblem

form id="salesForm"
  ...
  .form-group
    label Some Sales Info
      = input type="text" disabled=false value=salesNumber placeholder="Sales Number" class="form-control" required

  button{action: 'clickNSave'}
  ...

This gives me a build error, because emblem does not recognize required on the input.

How can I create a simple validation using jquery-validation on ember app that uses emblem for template?

Additional question, is my validation on index.html correct, to run the validation at the very end, right before closing body tag? If not, where is the best way to insert $('#someForm').validate();?




Aucun commentaire:

Enregistrer un commentaire