I have a table having some fields, I want to submit that table to database, but I want them to be validated to be required, therefore I put the table into a form and trying to validate them
form to be validated (required only):
<form id="trip-send-form">
<!--some field , this field is validated to be required successfully-->
<input type="text"
<!--but the fields here, are not being set to be required-->
<table>
<tbody ng-repeat="item in items">
<tr>
<td><input type="checkbox" ng-model="item.setRequired"</td>
<td><input type="text" ng-model="name" ng-required="item.setRequired" /></td>
</tr>
</tbody>
</table>
<input type="submit"/>
</form>
controller:
$('#send-trip-form').validator({
focus: false,
feedback: {
success: 'fa fa-ok',
error: 'fa fa-remove'
}
})
$('#send-trip-form').validator().on('submit', function(e) {
if (e.isDefaultPrevented()) {
console.log( "error" );
} else {
console.log( "success" );
}
})
I am waiting for your kind response.
Thanks.
<form>is a directive with plenty of validations. Give it a name and access validations with$scope.formName.$valid, etc. Also you can addng-submit="submit()"to call some function on submission event