0

Submit button validation to 3 selected li only

How to check if the selected modules are 3 or less than 3. When less than 3 prompt alert please select 3 modules. If selected 3 modules, prompt thank you for submission. $('#selectModule').click(function(){ if ('#moduleList li:gt(2)' == 3) { alert("Thank you. Your selected modules have been submitted."); } else { alert("Please select 3 modules for submission"); } });

23rd Feb 2020, 5:32 AM
SWL
1 Antwort
+ 1
I wud have a loop before With an if statement and counter If selected moduleList++ Then check if that value is greater than 3
23rd Feb 2020, 5:49 PM
Rodrigo Sanchez
Rodrigo Sanchez - avatar