How do I check for any empty field in a form using javascript

I want to be able to find an empty field in a dynamically created form.

Related tags: JavaScript PHP

Credit: own experience

function CheckFormForEmptyElements(form) {

        for (i=0; i<form.elements.length; i++) {
                if (form.elements[i].type == "text" && form.elements[i].value.length == 0){
                        txt = form.elements[i].name + " cannot be empty";
                        form.elements[i].style.background = "Yellow";
                        return false;
        return true; return CheckFormForEmptyElements(this.form);

Rating: 1

Propose a different solution...