Currently in my form I'm checking whether or not the field has a value and also length but I'm wondering if there's a way to check the file type on uploads as well?
This is my code for the presubmit >
editor.on( 'preSubmit', function ( e, o, action ) {
if ( action !== 'remove' ) {
var numOfFields = $('[data-editor-template]').length;
var fieldNames = Object.keys(this.s.fields);
var skip = ['home_sections.status_id','home_sections.section_image_id','home_sections.link'];
for(var i=0;i<numOfFields;i++){
if(fieldNames[i] == "home_sections.section_image_id"){
console.log(this.field(fieldNames[i]));
this.field(fieldNames[i]).error('This field can not be over 200 characters');
}
if(fieldNames[i] == "home_sections.link" && this.field(fieldNames[i]).val().length >= 200 ){
this.field(fieldNames[i]).error('This field can not be over 200 characters');
}
else {
if (skip.includes(fieldNames[i])) {
continue;
}
}
if(fieldNames[i] == "home_sections.title" && this.field(fieldNames[i]).val().length >= 75 ){
this.field(fieldNames[i]).error('This field can not be over 75 characters');
}
if( !this.field(fieldNames[i]).val() ) {
this.field(fieldNames[i]).error('This field can not be empty');
}
}
if ( this.inError() ) {
return false;
}
}
} );