0

I have a following form in my HTML code.

When I forget to fill in the surname, the form will show me a "bubble message" You have to fill in the surname, then I will fill in the surname, press the submit button and the values are submitted.

When I forget to change the default option from <select> the form will show me a "bubble message" You have to choose something, then I will choose another option, press the submit button, but the values are not submitted. I always have to refresh the page. Do you know where is the problem and how to achieve it without refreshing?

<form action="add" method="post">
  ...
  <select id="choice" name="choice" 
     required oninvalid="setCustomValidity('You have to choose something')" 
     oninput="setCustomValidity('')">
     <option value="" selected="selected"></option>
     <option value="first">first</option>
     <option value="second">second</option>
   </select>
   ...
   <input type="text" name="surname" id="surname" value=""
      required oninvalid="setCustomValidity('You have to fill in the surname')" 
      oninput="setCustomValidity('')">
    ...
 </form>
xralf
  • 3,312
  • 45
  • 129
  • 200
  • as I mentioned in my answer below there is no problem with submitting the values, that means you need to give the complete code example. – Timmerz Nov 08 '14 at 18:24
  • may [this](http://stackoverflow.com/questions/26658784/php-dropdown-option-selected/26659241#26659241) help you ? –  Nov 08 '14 at 18:25

1 Answers1

0

There is no problem with the form data submitting as you will see from this jsfiddle example:

http://jsfiddle.net/vbnh1a4y/

post example

<form action="/echo/html" method="post">
  <select id="choice" name="choice">
    <option value="" selected="selected"></option>
    <option value="first">first</option>
    <option value="second">second</option>
  </select>
  <input type="text" name="surname" id="surname" value="" />
  <input type='submit' />
</form>
Timmerz
  • 6,090
  • 5
  • 36
  • 49