Conditional validation in jquery validation engine

I have a checkbox and a text box. I require that if the checkbox is checked, the text field becomes forced. Conversely, if the text field is full, the checkbox becomes forced.

So the sample will be

Element name - Checkbox - Expiration date Item name2 - checkbox2 - Validity period2

Data is retrieved from the database in an array using a query.

My code looks like

<script type="text/javascript"> 
$(document).ready(function(){
    $("#sea").validationEngine();
   });

function industry(field, rules, i, options) {    
var atLeastOneIsChecked = $('input[name="extraqualification[]"]:checked').length > 0;
if (atLeastOneIsChecked == 1 )        {
if(document.getElementById('extraqualificationexpirydate<?php echo $extraqual['Id']?>').value=='')
{
   return "Please supply a certificate expiry";
}else{} }
    } </script>
+3
source share
1 answer

You need the conditional verification required. There is a method condRequiredthat you can use as follows:

<input value="" type="text" name="test" id="test" />
<input class="validate[condRequired[test]]" type="text" id="test_2" name="test_2"/>

Also, make sure you are using version 2.6 or higher.

+2
source

All Articles