tags:

views:

29

answers:

3

Hi all, I have a html form that sends the data from 2 fields (memer no. , pw) via axaj (getElementById)to php file to check them with database info. . I did every thing well but I want to reset both fields if one of them is incorrect . How can I send reset order back to html form ? notice - I didn't use submit button just normal button to keep in same page.

Thanks all

+1  A: 

You can place this statement at the appropriate place where you check for response:

document.getElementById('form_id').reset();
Sarfraz
A: 

Can you have the validation code returning an error status, then use JavaScript to set the value of the controls to blank.

Extrakun
A: 

Try this.

document.form_name.reset();
pavun_cool
where ? I just want it to reset once the php tells that the data is incorrect .how can I send this order from php to html page?
mjd
You can't, at least not directly. You can send some data in your response to the HTTP request. The callback you assign to the XHR object can look at that data and `if` it is some value, it can call that method.
David Dorward