twitter bootstrap 3 - BootstrapValidator: How to use use two submit buttons and validate different fields on same form? -


I have a form with two submit buttons, but for each I want to validate different areas in this area When I click on the Preview Submit button, I want to ignore 3 fields, while submit the 'normal' button, I want to validate all. Is this possible?

Here's some html:

  & lt; Form class = "form" role = "form" id = "searchesForm" & gt; & Lt; Input class = "form-control" type = "text" id = "name" name = "name" /> & Lt; Input class = "form-control" type = "text" id = "widgetWidth" name = "widgetWidth" /> & Lt; Input class = "form-control" type = "text" id = "widgetHeight" name = "widgetHeight" /> & Lt ;! - Valid more field click for both regions - & gt; ... & lt; Button type = "button" id = "preview" name = "preview search" category = "btn btn-default"> gt; Preview & lt; / Button & gt; & Lt; Button type = "submit" id = "submit" name = "submit" class = "btn btn-primary" & gt; Save & lt; / Button & gt; Therefore, the idea is that when I should press these 3 fields (name, widget widget and widget highlight) in the preview button  

$ ('#foodForm') bootstrapValidator ({Excluded [TD> TD> Input, TD> Text Area '], feedbackIcons: {Valid:' Glyphicon Glyphicon-OK ', Invalid:' Glyphicon Glyphicon-Extract ', Valid:' Glyphicon Glyphicon Fresh '}, live:' presented ', SubmitButtons:' [ty Pe = "submit"], field: {name: {validators: {notEmpty: {enable: function () {debugger; warning ("test");}, message: 'the question is necessary and can not be empty' }}}}}. ('Success.form.bv', function (e) {// stop form submission e.preventDefault (); // button on check button = $ (e.target) .data ('bootstrapValidator ') Was pressed getSubmitButton (); if ($ (button) .attr ("id") === "preview") {previewSearch (); / / ajax doing things} else {savesearch () ;. // ajax things}}} ('error.form.bv', function (e) {var invalidFields = $ (e.target) .data (on 'bootstrapValidator') .getInvalidFields (); // Places of specific areas Show tab $ .each for (invalidFields, function (index, value) {if ($ ("# filtrro s") (value). Length & gt; ($) ($ ("# Resultado"). ( Value) is the length 'gtc: ($)' $ '(' # '($ "' ('# tab li: ac (0)' tab ('show')} tab (li): (1) ('' Show ''}} ($ ("$"). (Value) Length & gt; 0) {$ ('# tabs li: eq (2) one'). Tab ('Show' }}}}}} ('Status.field.bv', function (e, data) on {if (data.bv.getSubmitButton ()) {data.bv.disableSubmitButtons (wrong);}. Bv.getSubmitButton ()) {If (Data.bv.getSubmitButton (). Attr ("id") === "preview") {if (data.field === "name" || data.field === "widgetWidth" || data.field === "widgetHeight") {data.bv. $ form.bootstrapValidator ('enableFieldValidators', data.field, 'notEmpty', incorrect);}} else {data.bv. $ form.bootstrapValidator ('enableFieldValidators', data .field, 'not element', true);}}})

I do not know where we can press area according to button Enable / disable verifier. I tried to change the status of field validation on .on ('status.field.bv' ...) method but it does not work perfectly

So whoever came from this situation ?


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -