Giter Site home page Giter Site logo

validator-demo's Introduction

Advanced jQuery Email Address Validator by Mailgun

Given an arbitrary address, Mailgun will validate the address based on:

  • Syntax checks (RFC defined grammar)
  • DNS validation
  • Spell checks
  • Email Service Provider (ESP) specific local-part grammar (if available)

How to use the email validator on your form

  1. Include jQuery
  2. Include mailgun_validator.js
  3. Sign up for a Mailgun account and insert your public API key
  4. Attach mailgun_validator() function to the email field you want validated
  5. Decide what should happen for valid emails, invalid emails and suggestions

Attaching to a form field:

   $('jquery_selector').mailgun_validator({
       api_key: 'api-key',
       in_progress: in_progress_callback, // called when request is made to validator
       success: success_callback,         // called when validator has returned
       error: validation_error,           // called when an error reaching the validator has occured
   });

Sample JSON in success callback:

 {
     "is_valid": true,
     "parts": {
         "local_part": "[email protected]",
         "domain": "example.com",
         "display_name": ""
     },
     "address": "[email protected]",
     "did_you_mean": null
 }

Demo

http://mailgun.github.io/validator-demo/

More information

validator-demo's People

Contributors

eddywashere avatar jeremyschlatter avatar msigley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

validator-demo's Issues

Selector

Can you add the original selector value? I want to do this:

$('input[type="email"]').mailgun_validator({
api_key: 'pubkey-XXXXXXXXXX',
in_progress: function(){
console.log('MG Validating');
},
success: function(data){
if (!data.is_valid) {
mailgunError($(this).selector, data);
} else {
mailgunSuccess($(this), data);
}
},
error: function(){
}
});

When upgrade to v3

I notes the latest mailgun API is v3, when to upgrade to v3 in your plan?

Thanks.

Exposing API Key to the Public

Am I correct in stating that by putting the API key in a jQuery plugin it'd allow for people to send emails on my behalf provided that they new the domain of the account?

It seems like all they'd have to figure out is the domain which would be in the header information for all the emails sent.

Am I overlooking something or should we really have a client validation API key in addition to a sending email api?

change instead of focusout?

I know duplicates are caught, but wouldn't running on change instead of focusout be simpler and have a little better performance?

Submit form when email is valid

Hi, I'm using your validator for an email in a form. I can't figure out how to submit the form when the email is valid. I tried with $('#form').submit(); and many other ways but it works only when I click again and the validator doesn't validate because it is the same email.

validation_error bug in the demo example

It looks like there's a bug with how error validation_error function works.
https://github.com/mailgun/validator-demo/blob/master/index.html#L88

// if email is invalid
      function validation_error(error_message) {
        $('#status').html(error_message);
      }

$('#status').html(error_message); does not fire.

The "Address is invalid." check and error message does work properly, but it is fired inside validation_success function as the last remaining "else" condition.

You can easily test this by removing $('#status').html(error_message); and testing validator. You'll see it still works just fine. This is a problem because if we want to do something else when email is invalid, let's say addClass it does not work.

No validation on first call

Hi,

The first call I make to mailgun_validator doesn't really happen. I've checked the network log and there is no validation requests. I then focus on the element that calls the validation, blur and the call is correctly made.

This is my code:

$("#email").blur(validateEmail);

var validateEmail = function() {
    var email = $("#email");
    if (email.val() !== "") {
        email.mailgun_validator({
               api_key: 'XXXXXXX',
               in_progress: in_progress_callback, // called when request is made to validator
               success: success_callback,         // called when validator has returned
               error: validation_error,           // called when an error reaching the validator has occured
        });
};

I have logs in every method and I see that after the first call neither success_callback nor validation_error are called. Any ideas?

Security Issue

Is it really okay to expose our API Key?
e.g. api_key: 'api-key'

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.