2017-10-15 1 views
0

Ich benutze BootstrapValidator (identisch) zu überprüfen, beide E-Mails sind gleich oder nicht, es funktioniert gut, aber ich möchte Fehlermeldungen in der gleichen Zeile, jetzt sind sie in zwei Zeilen. Siehe hier https://screenshots.firefox.com/abfJ97LEjpAncVoW/localhost. Ich habe viel versucht und in Google gefunden, aber keine Lösung bekommen. . Meine Validierungscode folgend:Wie validiere ich beide E-Mails mit bootstrapValidator (identisch)

$('#formid').bootstrapValidator({ 

     feedbackIcons: { 
      valid: 'glyphicon glyphicon-ok', 
      invalid: 'glyphicon glyphicon-alert', 
      validating: 'glyphicon glyphicon-refresh' 
     }, 
     fields: { 
      firstmail: { 
       validators: { 
        notEmpty: { 
         message: 'The email address is required and can\'t be empty' 
        }, 
        emailAddress: { 
         message: 'The input is not a valid email address' 
        }, 
        identical: { 
         field: '2ndmail', 
         message: 'The email and its confirm are not the same' 
        } 
       } 
      }, 
      2ndmail: { 
       validators: { 
        notEmpty: { 
         message: 'The email address is required and can\'t be empty' 
        }, 
        emailAddress: { 
         message: 'The input is not a valid email address' 
        }, 
        identical: { 
         field: 'firstmail', 
         message: 'The email and its confirm are not the same' 
        } 
       } 
      }, 
      }, 

    }) 

Antwort

0

folgenden Code mein Problem gelöst, habe ich es unter diesem $ ('# formid') bootstrapValidator ({.....}) hinzugefügt;

$('#formid').bootstrapValidator({ 

feedbackIcons: { 
    valid: 'glyphicon glyphicon-ok', 
    invalid: 'glyphicon glyphicon-alert', 
    validating: 'glyphicon glyphicon-refresh' 
}, 
fields: { 
    firstmail: { 
     validators: { 
      notEmpty: { 
       message: 'The email address is required and can\'t be empty' 
      }, 
      emailAddress: { 
       message: 'The input is not a valid email address' 
      }, 
      identical: { 
       field: '2ndmail', 
       message: 'The email and its confirm are not the same' 
      } 
     } 
    }, 
    2ndmail: { 
     validators: { 
      notEmpty: { 
       message: 'The email address is required and can\'t be empty' 
      }, 
      emailAddress: { 
       message: 'The input is not a valid email address' 
      }, 
      identical: { 
       field: 'firstmail', 
       message: 'The email and its confirm are not the same' 
      } 
     } 
    }, 
    }, 

}) 

.on('error.validator.bv', function(e, data) { 
// $(e.target) --> The field element 
// data.bv  --> The BootstrapValidator instance 
// data.field  --> The field name 
// data.element --> The field element 
// data.validator --> The current validator name 

data.element 
    .data('bv.messages') 
    // Hide all the messages 
    .find('.help-block[data-bv-for="' + data.field + '"]').hide() 
    // Show only message associated with current validator 
    .filter('[data-bv-validator="' + data.validator + '"]').show(); 
}); 
Verwandte Themen