Skip to content

Commit

Permalink
Add some form validation for sites
Browse files Browse the repository at this point in the history
  • Loading branch information
gmjosack committed Jan 4, 2015
1 parent 18dba7c commit d63ecd7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
18 changes: 13 additions & 5 deletions nsot/static/templates/site.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,25 @@
<div ng-if="updateError" class="alert alert-danger">
[[updateError.code]] - [[updateError.message]]
</div>
<form novalidate class="nsot-form">
<div class="form-group">
<form novalidate name="siteForm" class="nsot-form">
<div class="form-group" ng-class="{
'has-error' : siteForm.name.$invalid,
'has-success' : siteForm.name.$valid,
}">
<input type="text"
class="form-control"i
placeholder="Name"
class="form-control"
name="name"
placeholder="Name (required)"
ng-model="site.name"
ng-minlength="1"
required
>
</div>
<div class="form-group">
<textarea style="resize: vertical;"
class="form-control"
rows="5"
name="description"
placeholder="Description"
ng-model="site.description"
>
Expand All @@ -42,7 +48,9 @@
<button type="button" class="btn btn-default" data-dismiss="modal">
Close
</button>
<button type="submit" ng-click="updateSite(site)" class="btn btn-primary">
<button type="submit" ng-click="updateSite(site)"
class="btn btn-primary" ng-disabled="siteForm.$invalid"
>
Update
</button>
</div>
Expand Down
20 changes: 14 additions & 6 deletions nsot/static/templates/sites.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,25 @@
<div ng-if="error" class="alert alert-danger">
[[error.code]] - [[error.message]]
</div>
<form novalidate class="nsot-form">
<div class="form-group">
<form novalidate name="siteForm" class="nsot-form">
<div class="form-group" ng-class="{
'has-error' : siteForm.name.$invalid,
'has-success' : siteForm.name.$valid,
}">
<input type="text"
class="form-control"i
placeholder="Name"
class="form-control"
name="name"
placeholder="Name (required)"
ng-model="site.name"
ng-minlength="1"
required
>
</div>
<div class="form-group">
<textarea style="resize: vertical;"
class="form-control"
rows="5"
name="description"
placeholder="Description"
ng-model="site.description"
>
Expand All @@ -37,11 +43,13 @@
<button type="button" class="btn btn-default" data-dismiss="modal">
Close
</button>
<button type="submit" ng-click="createSite(site)" class="btn btn-primary">
<button type="submit" ng-click="createSite(site)"
class="btn btn-primary" ng-disabled="siteForm.$invalid"
>
Create
</button>
</div>
</div>
</nsot-modal>

<div ng-if="!sites.length" class="row"><div class="col-sm-6 col-sm-offset-3">
<panel>
Expand Down

0 comments on commit d63ecd7

Please sign in to comment.