View Full Version : Jquery selectbox validations

02-15-2013, 07:22 PM
I have the following code working in Jquery.

I need to display the message "Year Required" when the value or option value of select element is "0".
My coding is as follows

<script type="text/javascript">
$(document).ready(function () {

debug: true,
rules: {
year: { required: function () { return ($("#year option:selected").val() == "0"); } }

messages: {
year: "Year Required",

Select box coding

<select name="year" id="year">
<option value="0">Year</option>
<option value="1">1919</option>
<option value="2">1920</option>
<option value="3">1921</option>
<option value="4">1922</option>

For the above coding IE is not showing any errors. but the validations is not working. your suggestions shall be highly appreciated