WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. openpower
    Member
    Posted 1 year 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 12 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 10 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 10 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 10 months ago #

    Awesome jquery Xerces!

  6. happygentel
    Member
    Posted 5 months ago #

    +1 like xerces!

  7. happygentel
    Member
    Posted 5 months 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>

  8. Andrew Davis
    Member
    Posted 1 month ago #

    I suggest changing Line #9 of zip.xerces (Jeff Weiss) code to this:

    var pattern=/(^[a-zA-Z0-9_.+-]+)@([a-zA-Z0-9_.-]+).([a-zA-Z]{2,15}$)/i;

    The way Jeff's code is written, the following VALID emails will all Fail with an Error:

    andrew0@email.com
    andrew@99email.com
    andrew@email.co.uk
    andrew0@email.international
    etc...

    The code change I supplied should fix those.

    Thanks and great work, by the way, Jeff!
    Your code is very useful.
    -Andrew

  9. Andrew Davis
    Member
    Posted 1 month ago #

    Another fix:
    Line #3 can be changed to this:

    jQuery('input.sml_submitbtn').bind('click', function() {

    The 'input[name="submit"]' portion of the original code, will target ANY Input Button on that page, which carries the name "submit" (which most Input Buttons do).

    I have a comment box on my site, and I noticed that it was triggering the warning messages incorrectly, when I attempted to submit a comment.

    This fix I made, solves the problem.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic