(function($) { $(document).ready(function(){ site = 'uk'; var mandatory_fields = ['name', 'email', 'company', 'company-address', 'postal-code', 'locality', 'country', 'phone']; /* // Remove array value function arrayRemoveValue(a,v) { var n = new Array(); for(var i=0; i < a.length; i++) { if(a[i].toString() != v.toString()) { n.push(a[i]); } } return n; } */ function remove_mark(f) { var e = $('#'+f); e.on('keypress change', function(){ $(this).parent().find('.check_errors_msg').remove(); $(this).removeClass('has-error'); }); } // Show field other language when Other is selected (language is not in the predefined list) $("#source-lang").change(function(){ if ( $(this).val() == "other" ){ $("#source-lang-other").show(); } else $("#source-lang-other").hide(); }); $("#target-lang").change(function(){ if ( $(this).val() == "other" ){ $("#target-lang-other").show(); } else $("#target-lang-other").hide(); }); $("#country").change(function(){ if ( $(this).val() == "other" ){ $("#country-other").show(); } else $("#country-other").hide(); }); //(function($) { 'use strict'; // Change this to the location of your server-side upload handler: var url = '/bo/translation/v1/server/'; $('#fileupload').fileupload({ url: url, dataType: 'json', done: function (e, data) { $.each(data.result.files, function (index, file) { if(file.error) { var t = '' + file.name + ' ' + file.error + ''; $('

').html(t).attr('class','error not-uploaded').appendTo('#files'); } else { var t = ''; $('

').html(t).appendTo('#files'); } // console.log(file); }); }, progressall: function (e, data) { var progress = parseInt(data.loaded / data.total * 100, 10); $('#progress .progress-bar').css( 'width', progress + '%' ); } }).prop('disabled', !$.support.fileInput) .parent().addClass($.support.fileInput ? undefined : 'disabled'); // Form validation $("#free-translation-form").submit(function(){ $('.check_errors_msg').remove(); var checkErrors = false; for(var i=0; i < mandatory_fields.length; i++) { if ($('#' + mandatory_fields[i]).val() == '') { //var type = $('#' + mandatory_fields[i]).get(0).tagName; //console.log(mandatory_fields[i] + ' => ' + type); $('#' + mandatory_fields[i] + '-c').append('Required field'); $('#' + mandatory_fields[i]).addClass('has-error'); checkErrors = true; } } if(checkCaptcha && $('#g-recaptcha-response').val() == '') { $('#recaptcha_c').append('Captcha test not performed'); checkErrors = true; } if(checkErrors) { var msg = '

'; $('#submit_c').before(msg); $('#check_result_errors').slideDown({duration:400}); return false; } }); for (var i in mandatory_fields) { remove_mark(mandatory_fields[i]); } }); })(jQuery)