Validating all fields on a form

The following Javascript can be used to verify that a value has been entered in all fields on a form.

function validate(form) {
    var regex = /\w+/;
    for(var i = 0; i < form.length; i++) {
        var curr_el = form.elements[i];
        if(!regex.test(curr_el.value)) {
            alert("Please fill out all fields.");
            return false;
    return true;			
This entry was posted in JavaScript. Bookmark the permalink.

Warning: count(): Parameter must be an array or an object that implements Countable in /homepages/5/d154205736/htdocs/wordpress/wp-includes/class-wp-comment-query.php on line 405

Comments are closed.