0

Hallo ich benutze BootstrapValidator. Die E-Mail-Validierung zählt diese [email protected] gültig anstelle von [email protected].Bootstrap-Validator für E-Mail-Adresse

<div class="col-sm-4 form-group"> 
    <div class="error-icon"> 
     <label class="control-label">Email</label> 
     <input class="form-control" id="person_email" name="person_email" placeholder="eg: [email protected]" type="email"> 
    </div> 
</div> 

Script

$('#basicBootstrapForm').bootstrapValidator({ 
    feedbackIcons: { 
     valid: 'glyphicon glyphicon-ok', 
     invalid: 'glyphicon glyphicon-remove', 
     validating: 'glyphicon glyphicon-refresh' 
    }, 
    fields: { 
     person_email: { 
      validators: { 
       notEmpty: { 
        message: 'The email address is required' 
       }, 
       person_email: { 
        message: 'The input is not a valid email address' 
       } 
      } 
     }, 
    } 
}); 

Jede Hilfe würde geschätzt.

+0

Mögliche Duplikat sein [Validate E-Mail-Adresse in JavaScript?] (Http://stackoverflow.com/questions/46155/validate-email- address-in-javascript) – Tgsmith61591

Antwort

2

Mit dem Validator regexp können Sie den Ausdruck der E-Mail-Adresse definieren.

regexp: { 
    regexp: '^[^@\\s][email protected]([^@\\s]+\\.)+[^@\\s]+$', 
    message: 'The value is not a valid email address' 
} 

Validierung Skript

$('#basicBootstrapForm').bootstrapValidator({ 
    feedbackIcons: { 
    valid: 'glyphicon glyphicon-ok', 
    invalid: 'glyphicon glyphicon-remove', 
    validating: 'glyphicon glyphicon-refresh' 
    }, 
    fields: { 
    person_email: { 
     validators: { 
     notEmpty: { 
      message: 'The email address is required' 
     }, 
     regexp: { 
      regexp: '^[^@\\s][email protected]([^@\\s]+\\.)+[^@\\s]+$', 
      message: 'The value is not a valid email address' 
     } 
     } 
    }, 
    } 
}); 

Fiddle

+0

Vielen Dank habe ich auch \ .. nach dem vorletzten +, so dass es die .com ^ [^ @ \\ s] + @ ([^ @ \\ s] + \ \.) + \ .. [^ @ \\ s] + $ – Skillie

+0

Danke dafür! Ich habe bemerkt, dass Großbuchstaben standardmäßig verboten sind, gibt es eine Möglichkeit, sie durch Regexp zu erlauben? – Greg

Verwandte Themen