I need to make an element lose focus when I submit a form.
document.getElementById('element_name').blur(); works perfectly.
The thing I need is to know how to submit all elements on the page so that I don't have to manually enter every text box in the JS code.
Can you make all forms on the page lose focus?
I'm doing this because on touch screen devices, if you have the virtual keyboard open and submit via Ajax it doesn't close the keyboard so I want to lose focus on all elements whenever I submit via Ajax.
As mentioned, document.getElementById('element_name').blur() works perfectly if you manually enter each element name (and they virtual keyboard closes), I just want to know if there is an easy way to lose focus on all fields, and I can then tack it onto the end of my Ajax function and never have to think about it again (rather than making it a part of every page I create).
Have you tried:
I don't think that has anything to do with it (unless I am completely mistaken).
I think your code will change the colour of the text box when it is clicked on.
Do you want to lose focus on all fields onsbumit of the form button? if yes I think the following code would help you.
This topic is now closed. New replies are no longer allowed.