javascriptformsvalidationparsley.js

parsley.js select list value of zero - not working


I have a select list on my test form that I am trying to get to work with parsley.js validation.

The parsley validation does work, but only when the default value of the select list is a blank value, except I need to have a value of 0 (zero).

So when the value of zero is selected / displayed in the select list the select list should be red with indicating that there is an error.

How do I get the select list to validate correctly, when I am using a default value of zero?

Here is an example of my select list with the zero value:

<select name="availability_type" id="id_availability_type" data-parsley-id="1601" data-parsley-required="true" data-parsley-required-message="You must enter at least one Detail." class="input-xlarge2 standard_input_style parsley-success">
    <option value="0"> Do not display Availability</option>
    <option value="1">Immediately</option>
    <option value="2">1 week</option>
    <option value="3">2 weeks</option>
    <option value="4">3 weeks</option>
    <option value="5">4 weeks</option>
    <option value="6">&gt; 4 weeks</option>
</select>

Here is the code line that works with a blank space as the value:

<option value=" "> Do not display Availability</option>

Solution

  • I finally got this to work using the data-parsley-min="1".

    This way the input will not accept the value of zero.

    Hope that this helps some one.