how to submit form using jquery mobile?

How can I disable the submit button until all of the fields from the form are filled using javascript?

  • The form has a textbox and 3 dropdownlists. These are their id names: '#name (textbox), #country, #type, #adult'. I inserted in the select of the form.. I want them to be able to pick the options which has a value and after all dropdownlists and textbox has a value the submit button will enable. I can't figure it out.

  • Answer:

    Use jQuery. The code is something like this: $('#submit').click(function(){ if ($('#name').val() == "") invalidForm() ; if ($('#country').val() == "") invalidForm() ; if ($('#type').val() == "") invalidForm() ; if ($('#adult').val() == "") invalidForm() ; return true; }); function invalidForm() { alert('please fill in the form'); return false; }

Ryuko at Answerbag.com Visit the source

Was this solution helpful to you?

Other answers

You attach a handler to the submit button. Your handler checks that everything is OK when submit gets clicked. Yes: return True and form submits. No: return False, and form does not submit (you can put up an error message too). There are other ways, but thats pretty easy.

Scumop

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.