First you should have a form to check for example here we have
then you may now check either user puts a valid data or not by using the script,
so now you will be able to validate your form at client side as its easy to learn and handle.
the function in the script can call in the onsubmit even of the form and the action converted to the # sign.
I found this is easy so i share it with you to learn from it.
Hope you learn from it