first javascript form validation implementation
This commit is contained in:
@ -71,10 +71,10 @@ function fillDropdownByValue(value, dropdownToFill) {
|
||||
|
||||
// Hides the default browser-upload-form and replaces it by an button
|
||||
function customizeUploadButton() {
|
||||
$(".tfile").before('<button id="button-file" type="button" class="btn btn-default"><span class="text">Upload...</span><span class="glyphicon glyphicon-open-file" aria-hidden="true"></span></button>');
|
||||
$(".tfile").hide();
|
||||
$("input.file").before('<button id="button-file" type="button" class="btn btn-default"><span class="text">Upload...</span><span class="glyphicon glyphicon-open-file" aria-hidden="true"></span></button>');
|
||||
$("input.file").hide();
|
||||
$('body').on('click', '#button-file', function() {
|
||||
$(".tfile").trigger('click');
|
||||
$("input.file").trigger('click');
|
||||
});
|
||||
}
|
||||
|
||||
@ -97,6 +97,22 @@ function setDropdownButtonText(text, dropdownButton) {
|
||||
dropdownTextSpan.innerHTML = text
|
||||
}
|
||||
|
||||
function validateForm() {
|
||||
valid = true
|
||||
file = document.querySelectorAll("input.file")[0]
|
||||
category = document.querySelectorAll("input.category")[0]
|
||||
subcategory = document.querySelectorAll("input.subcategory")[0]
|
||||
torrentname = document.querySelectorAll("input.name")[0]
|
||||
description = document.querySelectorAll("textarea.description")[0]
|
||||
if(file.value.length <= 0) { valid = false }
|
||||
if(category.value.length <= 0) { valid = false }
|
||||
if(subcategory.value.length <= 0) { valid = false }
|
||||
if(torrentname.value.length <= 0) { valid = false }
|
||||
if(description.value.length <= 0) { valid = false }
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function chunk(string, n) {
|
||||
var ret = "";
|
||||
for(var i=0, len=string.length; i < len; i += n) {
|
||||
|
Reference in New Issue
Block a user