Alexandru Vlas
Alexandru Vlas

Reputation: 1415

How to AUTO-EMPTY fields in a form AFTER submission

I'm using this ( http://www.j-download.com/demo/demo-j-dcontact.html ) form on my website. It works great but the only issue is that AFTER successfull submission ALL the fields are STILL FILLED. Can somebody please help me with this, I would like so the fields are auto-emptied after successfull submission..

Thanks.

Upvotes: 2

Views: 1961

Answers (1)

krystan honour
krystan honour

Reputation: 6833

can be acheived with jquery or raw javascript after the post and it is explained here

This script is from that site (in case the link dies)

function clear_form_elements(ele) {
    $(ele).find(':input').each(function() {
        switch(this.type) {
            case 'password':
            case 'select-multiple':
            case 'select-one':
            case 'text':
            case 'textarea':
                $(this).val('');
                break;
            case 'checkbox':
            case 'radio':
                this.checked = false;
        }
    });
}

you could also reset() the form

Upvotes: 7

Related Questions