Page 1 of 1

mandatory input document

Posted: Fri Oct 18, 2019 4:30 am
by manalidhuri
I want to display alert message using javascript, if input document is not uploaded in dynaform.
Is there any solution?

Thanks

Re: mandatory input document

Posted: Sun Oct 20, 2019 12:36 am
by programerboy
Hi,
What kind of file input you use in your dynaform? file or multipleFile?

Re: mandatory input document

Posted: Sun Oct 20, 2019 11:48 pm
by manalidhuri
multipleFile

Re: mandatory input document

Posted: Mon Oct 21, 2019 2:04 am
by programerboy
Hi,
If you checked the required checkbox of the multipleFile, the form check empty files automatically
But if you want check it with JavaScript a simple code is like this:
Code: Select all
function check_form(){
	var uploadedFiles = [];
	var uploadedFilesCount = $("input[name^='form[multipleFileVar005]']").length/3;
	for(var i=0;i<uploadedFilesCount;i++){
		if(document.getElementsByName('form[multipleFileVar005]['+i+'][appDocUid]').length > 0){
			var temp = [];
			temp[temp.length] = document.getElementsByName('form[multipleFileVar005]['+i+'][appDocUid]')[0].value;
			temp[temp.length] = document.getElementsByName('form[multipleFileVar005]['+i+'][name]')[0].value;
			temp[temp.length] = document.getElementsByName('form[multipleFileVar005]['+i+'][version]')[0].value;
			uploadedFiles.push(temp);
		}
		else
			break;
	}
	
	if(uploadedFiles.length == 0){
		alert('You must upload at least 1 file');
		return;
	}
	else if(uploadedFiles.length > 2){
		alert('You must upload maximum 2 files.');
		return;
	}
}
https://pmlearning.info
Thanks

Re: mandatory input document

Posted: Mon Oct 21, 2019 5:36 am
by manalidhuri
Thank you