Contact Bootstrapvalidator time, recently need a number of field co-verification, the web looked up a bit not found, consult the API documentation, found that can be achieved.
Look at Dom first.
<DivClass= "Form-group"><LabelClass= "Col-sm-3 Control-label"> End of Life:</Label><DivClass= "Col-sm-9 Row"><DivClass= "Col-xs-5"><DivClass= "Input-group"><InputType= "Text"Name= "Beginyear"Class= "Form-control"/><SpanClass= "Input-group-addon"> Year</Span></Div></Div><DivClass= "Col-xs-1"Style= "LINE-HEIGHT:36PX;"> To</Div><DivClass= "Col-xs-5"><DivClass= "Input-group"><InputType= "Text"Name= "Endyear" Class= " Form-control "/> < span class= " Input-group-addon "> year </ span> </div> </div< Span style= "color: #0000ff;" >> </div>< Span style= "color: #0000ff;" ></div
In this form, we often need to start the year not later than the end of the year, and Beginyear<=endyear, at this point, verify that we can write this
Fields: {Beginyear: {validators: {integer: {}, Callback: { Message: ' Start date cannot be greater than end Date ', Callback:function(Value, validator, $field, Options) {var begin = $ (' #pro_info '). Find ("Input[name= ' endyear ']" return parseint (value) <=parseint (begin);} }}, Endyear: {validators: {integer: {}, Callback: {message: ' End date cannot be less than start date ' ). KeyPress (); Validator.updatestatus (' beginyear ', ' VALID ' ); return parseint (value) >=parseint (begin);} }}
The key is to use the callback function, passing in the parameter Validator Validator, using the validator to update the state of the specified field. This enables multi-field federation validation, of course, with three fields and four fields.
Reprint please indicate the source, blog Park: http://www.cnblogs.com/dreamowneryong/p/5000206.html; If in doubt, welcome to the original commentary and discuss together.
Bootstrapvalidator Multi-field joint validation (such as Start date and end date, start date not later than end date)