Skip to content

Commit

Permalink
Added frontend validation for creating files
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Furrer authored and dbrgn committed Jun 4, 2014
1 parent 0f00899 commit 16b6236
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions apps/filesystem/static/js/files.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
$(document).ready(function() {
setupDirectoryDropdown();
initValidation();
});

function setupDirectoryDropdown() {
Expand All @@ -21,3 +22,24 @@ function setupDirectoryDropdown() {
}
});
}

function initValidation() {
$('#fileform').validate({
rules: {
'name': {
required: true,
maxlength: 255
},
'dir': {
required: true
}
},
highlight: function (element) {
$(element).closest('.control-group').removeClass('success').addClass('error');
},
success: function (element) {
element.addClass('valid').closest('.control-group').removeClass('error').addClass("invisiblevalid");
},
ignore: ''
});
}

0 comments on commit 16b6236

Please sign in to comment.