function validateEmail(email) {
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}
var career_app = new Vue({
el: '#career_app',
data: {
full_name: '',
email: '',
phone: '',
job: '',
file:'',
isNotFile: false,
isFileBig: false,
errorInput: false,
},
methods: {
attach_file: function(event){
if (event) {
event.preventDefault();
event.stopImmediatePropagation()
}
$("#attached_file").trigger('click')
this.isNotFile = false;
this.isFileBig = false;
},
onSubmit(e) {
this.errorInput = !this.full_name || !this.email || !this.phone || !this.job;
if(this.errorInput){
e.preventDefault();
return;
}
if(!validateEmail(this.email)){
this.errorInput = true
this.email = ''
e.preventDefault();
return;
}
var file = this.$refs.file.files[0];
if (!file) {
e.preventDefault();
this.isNotFile = true;
return;
}
if (file.size > 3 * 1024 * 1024) {
e.preventDefault();
this.isFileBig = true;
return;
}
},
}
})