<script type="text/javascript"> $(function() { $("#techSkill").change(function() { if ($(this).val() == "X") { $("#techBox1").show(); } else { $("#techBox1").hide(); } }); }); $(function() { $("#techSkill").change(function() { if ($(this).val() == "Y") { $("#techBox2").show(); } else { $("#techBox2").hide(); } }); }); $(function() { $("#techSkill").change(function() { if ($(this).val() == "Z") { $("#techBox3").show(); } else { $("#techBox3").hide(); } }); }); // validation function validateForm() { var natsid = document.forms["student_registration"]["natsid"]; var techBox1 = document.forms["student_registration"]["techBox1"]; var techBox2 = document.forms["student_registration"]["techBox2"]; var techBox3 = document.forms["student_registration"]["techBox3"]; var comSk = document.forms["student_registration"]["comSk"]; var leadSk = document.forms["student_registration"]["leadSk"]; var mulSk = document.forms["student_registration"]["mulSk"]; var timeSk = document.forms["student_registration"]["timeSk"]; var analSk = document.forms["student_registration"]["analSk"]; var posiSk = document.forms["student_registration"]["posiSk"]; var att = document.forms["student_registration"]["att"]; var batch = document.forms["student_registration"]["batch"]; var avg = (parseInt(comSk.value) + parseInt(leadSk.value) + parseInt(mulSk.value) + parseInt(timeSk.value) + parseInt(analSk.value) + parseInt(posiSk.value)) / 9; console.log(avg) if (natsid.value == "") { document.getElementById("natsid_error").innerText = "Please enter your Registered NATS ID"; return; } if (natsid.value.length != 16) { document.getElementById("natsid_error").innerText = "Please enter your Registered Sixteen Digit NATS ID"; return; } document.getElementById("natsid_error").innerText = ""; if (techBox1.value < 8) { document.getElementById("tech_error").innerText = "You are not Eligible"; document.forms["student_registration"]["Submit"].disabled = true return; } if (techBox2.value < 8) { document.getElementById("tech_error").innerText = "You are not Eligible"; document.forms["student_registration"]["Submit"].disabled = true return; } if (techBox3.value < 8) { document.getElementById("tech_error").innerText = "You are not Eligible"; document.forms["student_registration"]["Submit"].disabled = true return; } if (avg > 8) { document.getElementById("form_error").innerText = "" document.forms["student_registration"]["Submit"].disabled = false } else { document.forms["student_registration"]["Submit"].disabled = true document.getElementById("form_error").innerText = "You are not Eligible" return; } if (parseInt(att.value) < 80) { document.getElementById("form_error").innerText = "You are not Eligible"; document.forms["student_registration"]["Submit"].disabled = true return; } else { document.getElementById("form_error").innerText = "" document.forms["student_registration"]["Submit"].disabled = false } } </script>
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter