www.webdeveloper.com
Results 1 to 6 of 6

Thread: Simple Alert

  1. #1
    Join Date
    Jan 2004
    Location
    Texas
    Posts
    8

    Exclamation Simple Alert

    I have this script.

    <script type='text/javascript'>

    $("li:has(div.err_msgs ul li) label").css('color', '#f00');

    </script>


    and when it runs it turns the label red - just like its supposed to.

    Now i want to add an alert that says, if it runs, then open alert box that says, 'you've missed a required field'

    any ideas?

  2. #2
    Join Date
    Oct 2009
    Location
    Manitoba
    Posts
    36
    I would try

    HTML Code:
    <script type='text/javascript'>
    
    $("li:has(div.err_msgs ul li) label").css('color', '#f00');
    {
    alert("you've missed a required field")
    return false;
    }
    </script>

  3. #3
    Join Date
    Jan 2004
    Location
    Texas
    Posts
    8

    Thumbs up

    i'll give it a try tomorrow and let you know. Thank you very much!

  4. #4
    Join Date
    Jan 2004
    Location
    Texas
    Posts
    8

    Cool

    yeah, that didn't work. it says, 'return is not a function'?

    $("li:has(div.err_msgs ul li) label").css('color', '#f00');
    {
    alert("You've missed a required field.")
    return false;
    }

  5. #5
    Join Date
    Jan 2004
    Location
    Texas
    Posts
    8
    $("li:has(div.err_msgs ul li) label").css('color', '#f00');
    {
    alert("You've missed a required field.")
    }

    This works, but it loads an alert everytime you load the page. and it should only happen when err_msgs is active.

  6. #6
    Join Date
    Jan 2004
    Location
    Texas
    Posts
    8
    This is how i solved it. Thanks for your help James

    $("li:has(div.err_msgs ul li) label").css('color', '#f00');
    if($("li:has(div.err_msgs ul li) label").length > 0)
    {
    alert("You've missed a required field.");
    }

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles