diff options
author | Struan Donald <struan@exo.org.uk> | 2013-03-01 13:00:36 +0000 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2013-03-01 13:00:36 +0000 |
commit | fcc995e2be0fcdbc6e45d985aff8435587c6227f (patch) | |
tree | f39713dc9c39d0f0ad62dc7606bb2f59ae19a624 /www/js/views/details.js | |
parent | cb43a115cce80e2ec6f1f9466523a30a1fc8377f (diff) |
validate the details screen before progressing
Diffstat (limited to 'www/js/views/details.js')
-rw-r--r-- | www/js/views/details.js | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/www/js/views/details.js b/www/js/views/details.js index 2647624..1b2eb6d 100644 --- a/www/js/views/details.js +++ b/www/js/views/details.js @@ -4,7 +4,43 @@ template: 'details', id: 'details-page', prev: 'photo', - next: 'submit' + next: 'submit', + + onClickButtonPrev: function() { + this.model.set('title', $('#form_title').val()); + this.model.set('details', $('#form_detail').val()); + this.model.set('category', $('#form_category').val()); + this.navigate( this.prev ); + }, + + onClickButtonNext: function() { + this.clearValidationErrors(); + var valid = 1; + + if ( !$('#form_title').val() ) { + valid = 0; + this.validationError( 'form_title', FMS.validationStrings.title ); + } + + if ( !$('#form_detail').val() ) { + valid = 0; + this.validationError( 'form_detail', FMS.validationStrings.detail ); + } + + var cat = $('#form_category').val(); + if ( cat == '-- Pick a category --' ) { + valid = 0; + this.validationError( 'form_category', FMS.validationStrings.category ); + } + + if ( valid ) { + this.clearValidationErrors(); + this.model.set('title', $('#form_title').val()); + this.model.set('detail', $('#form_detail').val()); + this.model.set('category', $('#form_category').val()); + this.navigate( this.next ); + } + } }) }); })(FMS, Backbone, _, $); |