javascript - Jquery validation not validate multi select box in form -
My page has two selected boxes (dropdpwn). I agree with my form using the jQuery validation plugin But this plugin is not valid, two selection boxes.
HTML: How to fix this problem for each () selection box Demo: $ ('Form'). Validate (function: {first name: {minlangha: 3, max length: 15, required: true}, last name: {minlength: 3, maxlength: 15, required: true}}, highlight: function (element) { AddClass ('is-error');}, unhighlight: function (element) {$ (element) .closest ('form-group'). RemoveClass (' Error: '; error'; error: element: 'span', error class: 'help-block', error placement: function (error, element) {if (element.parent ('input-group'). Length) { Error.insertAfter (element.parent ());} and {error.insertAfter (element);}}});
& lt; Form & gt; & Lt; Div class = "form-group" & gt; & Lt; = "Firstname" for label class = "control-label" & gt; Num: & lt; / Label & gt; & Lt; Div class = "input-group" & gt; & Lt; Span class = "input-group-connector" & gt; $ & Lt; / Span & gt; & Lt; Input class = "form-control" placeholder = "Insira o seu nome prĂ³prio" name = "firstname" type = "text" /> & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Div class = "form-group" & gt; & Lt; = "Lastname" for label class = "control-label" & gt; Apilido: & lt; / Label & gt; & Lt; Div class = "input-group" & gt; & Lt; Span class = "input-group-connector" & gt; € & lt; / Span & gt; & Lt; Input class = "form-control" placeholder = "Insira o seu apelido" name = "lastname" type = "text" /> & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Div class = "form-group" & gt; & Lt; = "Lastname" for label class = "control-label" & gt; Selectionbox 1 & lt; / Label & gt; & Lt; Div class = "input-group" & gt; & Lt; Span class = "input-group-connector" & gt; € & lt; / Span & gt; & Lt; Select class = "expected form-control" & gt; & Lt; Option value = "0" & gt; & Lt; / Options & gt; & Lt; Option value = "1" & gt; 1 & lt; / Options & gt; & Lt; Option value = "2" & gt; 2 & lt; / Options & gt; & Lt; / Select & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Div class = "form-group" & gt; & Lt; = "Lastname" for label class = "control-label" & gt; Selection box 2 & lt; / Label & gt; & Lt; Div class = "input-group" & gt; & Lt; Span class = "input-group-connector" & gt; € & lt; / Span & gt; & Lt; Select class = "expected form-control" & gt; & Lt; Option value = "0" & gt; & Lt; / Options & gt; & Lt; Option value = "1" & gt; 1 & lt; / Options & gt; & Lt; Option value = "2" & gt; 2 & lt; / Options & gt; & Lt; / Select & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Button type = "submit" class = "btn btn-primary" & gt; Submit & lt; / Button & gt; & Lt; / Form & gt;
1) You must have a unique name
attribute on each element This is a requirement of jQuery valid plugin.
2) The first should be the option
value = ""
and value = "0"
.
Working demo:
3) The demo of OP is broken because it is using the same id
twice for valid HTML, each id
Demo with ID:
Comments
Post a Comment