I have a simple javascript code to perform simple HTML form validation. This validation can only check whether the elements, that types are textbox, textarea and password in the form is empty or not.
Just follow the naming standard for each error label id.
For example:
<span style="visibility:hidden;" id="frm_simple_lblError0" class="Error">*</span>
The id attribute in the code above means:
frm_simpleis theidof the HTML form which will be validated.lblError0is the error labelidfor the firsttextboxortextareaorpasswordin the form.
In summary, frm_simple_lblError0 means an error label id for first textbox or textarea or password in the form with frm_simple as id.
Dont forget to add this code on the onsubmit event inside the form declaration.
For example:
<form name="frm_simple" onsubmit="return checkForm(frm_simple)" method="POST">
Of course you can customize (using others naming standard) or even enhance the code.
This is the complete code. (more…)


