I am trying to validate a Select element as follows:
<select name="block_name" id="block-name">
<option value="">Select Block</option>
<option value="blockA">Block A</option>
<option value="blockB">Block B</option>
</select>
which normally wouldn't be a problem if the rule was as Follows:
rules: {
block_name: {
required: true
}
}
As I would just add class="required"
to the select element.
But I am using a function in the rule as follows:
rules: {
block_name {
required: function(element) {
return $("#blocks").val() >= 2;
}
}
}
which uses the following hidden field which has a data binding that determines the value:
<input type="hidden" name="blocks" id="blocks" value="<?php echo $row_rsCurrentUser['blocks']; ?>">
When using this function in the rule
the class="required"
does not work thus excepting the default option element <option value="">Select Block</option>
How can I get this to validate but not except the default option as a selection?
Thanks in advance