<html><head><link rel="stylesheet" href="/vendors/@form-validation/umd/styles/index.min.css" /></head><body><form id="demoForm" method="POST">...</form><script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.35.3/es6-shim.min.js"></script><script src="/vendors/@form-validation/umd/bundle/popular.min.js"></script><script src="/vendors/@form-validation/umd/plugin-mailgun/index.min.js"></script><script>document.addEventListener('DOMContentLoaded', function(e) {FormValidation.formValidation(document.getElementById('demoForm'),{fields: {...},plugins: {...,mailgun: new FormValidation.plugins.Mailgun({apiKey: ...,field: ...,message: ...,suggestion: ...,}),},});});</script></body></html>
vendors
directory. You might need to change the path depending on where you place them on the server.Option | Type | Description |
---|---|---|
apiKey * | String | The API key provided by Mailgun |
field * | String | The field name that will be validated |
message * | String | Error message indicates the input is not valid |
suggestion | Boolean | Show suggestion if the email is not valid. By default, it is set to false |
$ npm install @form-validation/bundle$ npm install @form-validation/plugin-mailgun
import { formValidation } from '@form-validation/bundle/popular';import { Mailgun } from '@form-validation/plugin-mailgun';formValidation(document.getElementById('demoForm'),{fields: {...},plugins: {mailgun: new Mailgun({...}),...},});
Description | Sample |
---|---|
Does not meet Gmail minimum local-part length of 6 characters | john@gmail.com |
Invalid, because gmaill.com does not have valid MX records | john.smith@gmaill.com |
Invalid because while microsoft.io does not have any MX records, it does have fallback A records, but alas no Mail Exchanger responds | john@microsoft.io |
Meets Gmail 6 character minimum and all other requirements | john.smith@gmail.com |
Meets pure syntax checks | "hello world"@domain.com |
Suggest new email address | hello@gail.com |
<html><head><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" /><link rel="stylesheet" href="https://unpkg.com/tachyons@4.10.0/css/tachyons.min.css" /><link rel="stylesheet" href="/vendors/@form-validation/umd/styles/index.min.css" /></head><body><form id="demoForm" method="POST"><div class="cf mb2"><div class="fl w-100"><div class="fl w-25 pa2">Email address</div><div class="fl w-40"><input type="text" class="input-reset ba b--black-20 pa2 mb2 db w-100" name="email" /></div></div></div><div class="cf mb2"><div class="fl w-100"><div class="fl w-25 pa2"></div><div class="fl w-50"><button type="submit" class="ba b--black-20 bg-blue white ph3 pv2 br2">Submit</button></div></div></div></form><script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.35.3/es6-shim.min.js"></script><script src="/vendors/@form-validation/umd/bundle/popular.min.js"></script><script src="/vendors/@form-validation/umd/plugin-tachyons/index.min.js"></script><script src="/vendors/@form-validation/umd/plugin-mailgun/index.min.js"></script><script>document.addEventListener('DOMContentLoaded', function (e) {FormValidation.formValidation(document.getElementById('demoForm'), {fields: {email: {validators: {notEmpty: {message: 'The email address is required',},emailAddress: {message: 'The input is not a valid email address',},},},},plugins: {trigger: new FormValidation.plugins.Trigger(),tachyons: new FormValidation.plugins.Tachyons(),submitButton: new FormValidation.plugins.SubmitButton(),icon: new FormValidation.plugins.Icon({valid: 'fa fa-check',invalid: 'fa fa-times',validating: 'fa fa-refresh',}),mailgun: new FormValidation.plugins.Mailgun({// Put your Mailgun public API key hereapiKey: '...',field: 'email',message: 'The email address is not valid',suggestion: true,}),},});});</script></body></html>