Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jun 2008
    Posts
    682
    Thanks
    114
    Thanked 2 Times in 2 Posts

    Messages showing when shouldn't be

    When I have this form loading its loading both messages when I told it to hide it and don't know why. Does anyone else? I looked inside the source code of the form and it's not saying the jquery function is involved.


    Code:
    <script type="text/javascript">
        $(document).ready(function() {
        $('div.message message-error').hide();
        $('div.message message-success').hide();
        $("input.submit").click(function() {
            $('div.message message-error').hide();
            var divisionname = $("input#divisionname").val();
                    if (divisionname == "") {
            $("div.message message-error").show();
            $("input#name").focus();
            return false;
          }
            var dataString = 'divisionname='+ divisioname;
            $.ajax({
            type: "POST",
            url: "bin/process.php",
            data: dataString,
            success: function() {
            $("div.message message-success").show();
            return true;
        }
      });
      return false;    
        });
      });
     
    </script>
    <!-- Form -->
                                    <form action="" name="divisionform">
                                            <fieldset>
                                                    <legend>Add New Division</legend>
    
                                                    <div class="field required">
                                                            <label for="divisionname">Division Name</label>
                                                            <input type="text" class="text" name="divisionname" id="divisionname" title="Division Name"/>
                                                            <span class="required-icon tooltip" id="" title="Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. ">Required</span>
                                                    </div>
                                    <input type="submit" class="submit" name="submitdivision" id="submitdivision" title="Submit Division" value="Submit Division"/>
                                            </fieldset>
                                    </form>
                    <div class="message message-error">
                                            <h6>Required field missing</h6>
                                            <p>Please fill in all required fields. </p>
                                    </div>
                    <div class="message message-success">
                                            <h6>Operation succesful</h6>
                                            <p>Everything's going according to plan.</p>
                                    </div>
    <!-- /Form -->
    Last edited by CoolAsCarlito; 11-23-2010 at 11:32 PM.

  • #2
    New Coder
    Join Date
    Apr 2010
    Posts
    45
    Thanks
    0
    Thanked 8 Times in 8 Posts
    I think you need to change:

    Code:
    $('div.message message-error').hide();
    $('div.message message-success').hide();
    To:

    Code:
    $('div.message.message-error').hide();
    $('div.message.message-success').hide();
    Or:

    Code:
    $('div.message-error').hide();
    $('div.message-success').hide();
    Or:

    Code:
    $('.message-error').hide();
    $('.message-success').hide();
    Haven't tested it but hopefully that will do it
    BIOSTALL.com - Web Development Snippets, Hints and Tips

  • Users who have thanked BIOSTALL for this post:

    CoolAsCarlito (11-23-2010)

  • #3
    Regular Coder
    Join Date
    Jun 2008
    Posts
    682
    Thanks
    114
    Thanked 2 Times in 2 Posts
    Fixed. Thank you.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •