ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Finding EE code that generates all potential error messages when using the comment form so I can AJAX-it

February 11, 2011 2:30pm

Subscribe [2]
  • #1 / Feb 11, 2011 2:30pm

    northk

    51 posts

    Greetings all,

    I’m writing code that AJAX-ifies the EE comment entry form, similar to this thread:
    http://ellislab.com/forums/viewthread/177523/

    In order to do this, I need to see all HTML error pages that EE might generate when users fill out the comment form (such as name missing, email missing, comment missing, etc.). Then in my AJAX success: function I can check for each type of error and display an appropriate message in the form.

    I tried searching through the EE code to find out where these comment form errors are generated, but I can’t find it. I need to see the exact HTML text generated for each error, so that I can pattern-match against that text to “catch” it.

    I would appreciate help in finding where these errors are generated in the EE code (or maybe they’re in the DB?).

    Thanks

    -Northk

    If this isn’t clear, here is an example of what I’m talking about (in this case for the contact form):

    $(function() {
            $('#contact_form').ajaxForm({
                url: 'http://www.mywebsite.com',
                success: function(data) {
                    if (data.match(/<title>Error<\/title>/)) {
                        //grab the error message
                        var error = $(data).find('ul li:first').text();
            
                        // if they didn't enter any message, this is the error we'll get back from the server
                        if (error == 'Email Message is Required')
                            {
                                $('.contact-message').replaceWith('Please enter a message.');
                                
                            // else there was some other server message we got                    
                            } else { 
                                $('.contact-message').replaceWith('I apologize! For some reason the email could not be sent.');
                            }
                        } else {
                            // else no error, fix up a success message
                            $('.contact-message').replaceWith('Thanks for contacting me! Your email has been sent.');
                        }
                        // display the return message box
                        $('.contact-message-box').fadeIn(1000); 
                    },
                dataType: 'html'
            });
        });
  • #2 / Feb 11, 2011 3:55pm

    Sue Crocker

    26054 posts

    Hi, northk.

    The error messages can be found in comment_lang.php - is that what you’re looking for?

  • #3 / Feb 11, 2011 5:31pm

    northk

    51 posts

    Yes, that’s what I was looking for.

    Thanks very much!

    -NorthK

  • #4 / Feb 11, 2011 5:34pm

    Sue Crocker

    26054 posts

    Glad that helped. Don’t hesitate to post again as needed.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases