views:

28

answers:

2

See demo: http://tinyurl.com/3xow97t

The editor is under development. Now we check if it has an value - this works well with all form fields that have the class .required... but it does not work with the iframe.

the iframe has a div with id #content.

$('form .meet').focus(function() {
    $('iframe').each(function() {
    ** if($(this).contents().find('#content').val() == '') { **
        $(this).addClass('warning');
    }
    })
});

That means it should add the class .warning if the iframe is empty. But it always does, so what am i doing wrong?

Does it not work, because the JS does not see the text i currently typed in? ^^

Regards Henry

A: 

You're not doing anything wrong, per se, but #content is the <body> tag of your iframe, and I'm not sure what happens when you call .val() on the <body> element. Try substituting .val() with .text() and you should get the results you want.

$('iframe').each(function() {
    if($(this).contents().find('#content').text() == '') {
        $(this).addClass('warning');
    }
});

I verified that this works using Firebug, but let me know if it works on the actual page.

Intelekshual
A: 

Looks like this is working^^ ... thank you so much - you saved my day

Henry