Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
added 195 characters in body
Source Link
Half Blood Prince
  • 1.1k
  • 2
  • 16
  • 27

I made custom validation method for this. Here it is

$.validator.addMethod("maxFilesToSelect", function(value, element, params) { var fileCount = element.files.length; if(fileCount>2fileCount > params){ return false; } else{ return true; } }, 'Select no more than 2 files'); 

And specify rule as

policyBriefFiles: { extension:'xlsx,pdf', filesize: 2097152,   maxFilesToSelect : 2, }, 

Working as charm :-)

I made custom validation method for this. Here it is

$.validator.addMethod("maxFilesToSelect", function(value,element) { var fileCount = element.files.length; if(fileCount>2){ return false; } else{ return true; } }, 'Select no more than 2 files'); 

I made custom validation method for this. Here it is

$.validator.addMethod("maxFilesToSelect", function(value, element, params) { var fileCount = element.files.length; if(fileCount > params){ return false; } else{ return true; } }, 'Select no more than 2 files'); 

And specify rule as

policyBriefFiles: { extension:'xlsx,pdf', filesize: 2097152,   maxFilesToSelect : 2, }, 

Working as charm :-)

Source Link
Half Blood Prince
  • 1.1k
  • 2
  • 16
  • 27

I made custom validation method for this. Here it is

$.validator.addMethod("maxFilesToSelect", function(value,element) { var fileCount = element.files.length; if(fileCount>2){ return false; } else{ return true; } }, 'Select no more than 2 files');