There is a form with a validation check function.

As soon as you clicked send, the function is triggered and finds the wrong field. The user is informed about this in the form of a pop-up window, the value can also be changed there.

After that, it turns out that you need to return false on the validator and click the send button again. Even if we update the data in the required field - for the form they still remain the same and this is logical.

Is it possible to somehow update the data for the form at this stage?

Code for example:

 <form onsubmit="return valid();"> <input name="test" id="test1"> <input type="submit"> </form> <script> function valid(){ validVar = true; if($('#test1').val()==1)){ $('#test1').val(2); } return validVar; } </script> 

Such a code will be sent to form 1, if entered 1, how to send 2?

  • "if we update the data in the right field - they still remain the same for the form" - an example? - Igor
  • So it should be, judge for yourself - the data has passed into the form and is waiting for sending, we check them. In the process of checking, we change the field contents, but for the odds they remain the same, if we cancel the sending by the validator, then yes, they will be updated, but if we return that everything is good, it doesn’t matter what is written in the field, the data are already prepared and now go to the server - Zhenya Vedenin
  • "the data is in the form of" - the meaning of this phrase eludes me. Show the code. - Igor
  • Now add an example - Zhenya Vedenin

0