In order to enable the validator we must first include the JavaScript files:
<script type="text/javascript" src="tmt_core.js"></script>
<script type="text/javascript" src="tmt_form.js"></script>
<script type="text/javascript" src="tmt_validator.js"></script>
We must then add the tmt:validate attribute to the form tag. Without it the validator parser will completely skip our form:
<form action="index.htm" tmt:validate="true">
From now on we can take advantage of all the other attributes that can be used for input fields. The code for requiring a value to be entered in a simple text field looks like this:
<input type="text" name="myfield" tmt:required="true" tmt:message="Please insert your name" />
Here is the source code for the whole form:
<form action="index.htm" tmt:validate="true">
Name
<input name="myfield" type="text" class="required" tmt:required="true" tmt:message="Please insert your name" />
<input type="submit" value="Submit" />
</form>