Remove bunch of code. Just put a single line like below. Don't code any script to validate values of the form. XRule would save your time and effort.
XRule is totally free to use. Try it and enjoy your time. It's simple to use. Just add data-xr attribute to your input fields. That's it!
<script src="xrule.min.js"> <form onsubmit="return xr(this)"> <input data-xr="req() num()"> <input data-xr="req() email()"> <input data-xr="between(1, 10)"> <input type="submit"> </form>