开发者

JQuery Validate Mutli Select

I have following HTML and I am using JQuery Validation plugin. I want it so that if user selects first option "Select" it should not allow to post form.But its not working anyone knows why ? Its working fine for Select Dropdown but not wit multiple="multiple".

<select multiple="multiple" size="2">
  <option value="">Select</option>
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value=开发者_C百科"mercedes">Mercedes</option>
  <option value="audi">Audi</option>
</select>


The jQuery .val() method returns an array containing each selected option when working with elements. If no items are selected it'll return an empty array, and if the first item you listed is selected then the array will contain a single item that has a value of "".

You could try this instead:

<select multiple="multiple" size="2"> 
  <option></option> 
  <option value="volvo">Volvo</option> 
  <option value="saab">Saab</option> 
  <option value="mercedes">Mercedes</option> 
  <option value="audi">Audi</option> 
</select>

However, since it's a multiple select, do you really need a blank item anyway?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜