wizard html js -
unknown
plain_text
2 years ago
3.0 kB
7
Indexable
wizard script--- line not 27
{% if wizard.steps.current == '7' %}
<script type="text/javascript">
var file_error = [];
var actual_size = 10485760;
var forms = '{{formset.forms|length}}';
$(document).ready(function() {
$('#upload_doc_sub').click(function() {
console.log('Upload document submitted!');
if ($('.mentor').data('error-msg')){
$('.mentor').after('<span class="text-danger">' + $('.mentor').data('error-msg') + '</span>');
}
if ($('.employer').data('error-msg')){
$('.employer').after('<span class="text-danger">' + $('.employer').data('error-msg') + '</span>');
}
});
});
$(function () {
if ('{{document_submission_flag}}' == 'False') {
$('#upload_doc_sub').prop('disabled', true);
}
{% for form in formset.forms %}
file_error["{{form.file.auto_id}}"] = false;
$("#{{form.file.auto_id}}").change(function() {
if($(this).prop('files')[0].size>actual_size) {
$('#{{form.id.auto_id}}' + "_errors").html(
'* Please keep file size under ' +
Math.round((actual_size/1024)/1024, 2) +
' MB. Current file size is' +
Math.round(($(this).prop('files')[0].size/1024)/1024, 2) +
' MB.'
);
$(this).val('');
file_error[$(this).attr('id')] = true;
}
else if($(this).prop('files')[0].name.split('.')[0].length>25){
$('#{{form.id.auto_id}}' + "_errors").html("* File Name length should be less then 25.");
$(this).val('');
file_error[$(this).attr('id')] = true;
}
else if (
$.inArray(
$(this).val().substr(
$(this).val().lastIndexOf('.')+1
).toLowerCase(),
['pdf', 'jpeg', 'jpg', 'png', 'tiff', 'tif', 'zip', 'doc', 'docx']
) == -1
) {
$('#{{form.id.auto_id}}' + "_errors").html("* Incorrect file formats selected for upload, please ensure that only PDF, JPEG, PNG, TIFF, ZIP and DOC are chosen for upload.");
$(this).val('');
file_error[$(this).attr('id')] = true;
}
else{
$('#{{form.id.auto_id}}' + "_errors").html('');
file_error[$(this).attr('id')] = false;
}
if ($(this).hasClass('important') && $(this).prop('files').length === 0) {
file_error[$(this).attr('id')] = true;
} else {
file_error[$(this).attr('id')] = false;
}
});
{% endfor %}
});
</script>
{% endif %}Editor is loading...
Leave a Comment