WordPress.org

Ready to get started?Download WordPress

Forums

Mail Subscribe List
error message when the input is not a email (7 posts)

  1. openpower
    Member
    Posted 8 months ago #

    When I input nothing, or input a string withput @, the plugin show always the message of Thank you.
    How can I have an error message like "Email is not correct!" when the input is not an email.

    http://wordpress.org/plugins/mail-subscribe-list/

  2. duncanmoo
    Member
    Posted 8 months ago #

    Not a good idea to hack a module, but a quick solution to this is to change the email field sml_emailinput to an HTML5 email field rather than a text field, Line 85 of sml.php:

    $return .= '<p class="sml_email"><label class="sml_emaillabel" for="sml_email">'.$emailtxt.'</label><input class="sml_emailinput" name="sml_email" placeholder="'.$emailholder.'" type="email" value="" required="required"></p>';

    • changed type="text" to type="email"
    • added required="required"
  3. wwwolf
    Member
    Posted 7 months ago #

    Agreed this would be a good feature. Yes please :)
    (Hesitant to hack module and have to re-do after any update)

  4. zip.xerces
    Member
    Posted 7 months ago #

    I too was frustrated by this lack of form validation. What an oversight IMO. Anyway, this is what I did. Ideally, place this JQuery code in your HTML <head> tags, but anywhere at all in the page will do. A lot of my code like this ends up in a footer <div>.


    <script type="text/javascript">
    jQuery(document).ready(function() {
    jQuery('input[name="submit"]').bind('click', function() {
    var nameLength = jQuery('input[name="sml_name"]').val().length;
    if (nameLength < 3) {
    alert ("Please enter at least 3 letters for name");
    return false;
    }
    var pattern=/(^[a-zA-Z_.+-]+)@([a-zA-Z_-]+).([a-zA-Z]{2,4}$)/i;
    var email = jQuery('input[name="sml_email"]').val();
    if (pattern.test(email))
    return true;
    else {
    alert ("Please enter a valid email address");
    return false;
    }
    });
    });
    </script>

    - Jeff Weiss

  5. seedpxwee5
    Member
    Posted 6 months ago #

    Awesome jquery Xerces!

  6. happygentel
    Member
    Posted 1 month ago #

    +1 like xerces!

  7. happygentel
    Member
    Posted 1 month ago #

    Hi i have added 2 radio buttons on the subscription form, but i can make the error appear..please advise what's wrong with my code..THANKS!

    <script type="text/javascript">
    jQuery(document).ready(function() {
    jQuery('input[name="submit"]').bind('click', function() {

    var nameLength = jQuery('input[name="sml_name"]').val().length;
    if (nameLength < 3) {
    alert ("Please enter at least 3 letters for name");
    return false;
    }

    var pattern=/(^[a-zA-Z_.+-]+)@([a-zA-Z_-]+).([a-zA-Z]{2,4}$)/i;
    var email = jQuery('input[name="sml_email"]').val();
    if (pattern.test(email)) {
    return true;
    }
    else {
    alert ("Please enter a valid email address");
    return false;
    }

    if (jQuery("input[name='sml_age_13_up']").is(':checked')) {
    return true;
    }
    else {
    alert('Please confirm age.');
    return false;
    }

    });
    });
    </script>

Reply

You must log in to post.

About this Plugin

About this Topic