So I modified the function which is as below: Working on the issue myself, and that's what I've got so far.
This more or less works, but it's impossible to add minus afterwards due to the new value check.
If correct, the application allows the data to be submitted to the server and (usually) saved in a database; if not, it gives you an error message explaining what corrections need to be made.
Since the time you posted the question, I experimented your issue for an hour using different techniques.
It now seems to me that through an event on an input, you cannot set focus on itself.
JS: On Leave event or the blur even of every control you can call the validate() function. so it will stuck to the textbox till the valid data is put.