meteor form validation using parsley -


i have no clue how going, have followed steps on meteor parsley package.

i want form not submitted if there no valid input. though show undefined when added url, want restrict form submitting until satisfies condition.

<form class="form-horizontal" role="form" id="additem" data-parsley-validate>     <div class="form-group form-group-sm">   <label class="col-sm-2 control-label"           for="sm">listing url</label>   <div class="col-sm-3">     <input  type="url"              class="form-control"              id="listing_url"              placeholder="enter listing url"             data-required='true'             data-type='url'             data-trigger='change'/>    </div> </div> <div class="container ">     <div class="panel-footer">          <button class="btn btn-danger btn-md">clear</button>         <button class="btn btn-success btn-md pull-right submit">submit</button>     </div> </div> 

    template.additem.events({   'click .submit': function() {     var current_date = moment().format("dd-mm-yyyy hh:mm");     var insertform = {       created_at: current_date,       url: $('#url').val()     }         console.log('insertform:', insertform);         insertform.insert(insertform);       } }) template.additem.onrendered = (function () {   // setup parsley form validation   // replace form id of form   $('#additem').parsley({trigger: 'change'}); }); 

you need check if form's valid , run submit code.

    var formvalid = $('#additem').parsley('validate')     if (formvalid)     {         var current_date = moment().format("dd-mm-yyyy hh:mm");         var insertform = {             created_at: current_date,             url: $('#url').val()          }         console.log('insertform:', insertform);         insertform.insert(insertform);      } 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -