When things go wrong...

Backward compatibility

Version 2.0 introduced some backward compatibility issues. If you use the Validator out of the box you don't need to worry. If you were using custom rules/patterns or conditional validation with version 1.x, your code requires some minor tweaking

Custom rules and custom patterns now use JavaScript namespaces. So, for example, a 1.x pattern that looks like this:

tmt_globalPatterns.httpstart = new RegExp("^http://");

Under version 2.x must be renamed to:

tmt.validator.patterns.httpstart = new RegExp("^http://");

Conditional validation was redesigned from the ground up, making it more flexible. The 1.x code style:

tmt:required="conditional"

Must be converted to something like:

tmt:required="yourFunctionName"

Please check sample and explanation for additional details

Case sensitivity

Since it makes heavy use of DOM, XHTML and JavaScript, everything inside the TMT Validator is case sensitive. The whole library has been designed with power users in mind, so it doesn't tolerate sloppy coding (most of the time it will fail silently instead of throwing JavaScript errors)

The submit button's value isn't passed to the server-side script

By default submit buttons are disabled after the form is submitted. This prevents multiple submits but also prevents the value of the submit buttons from being passed as part of the HTTP request. Set the tmt:blocksubmit attribute of the <form> tag to false if you want prevent this behavior

About the onsubmit event of the <form> tag

Starting with version 1.3.0 the TMT Validator doesn’t takes anymore full control over the onsubmit event of the form tag. So, something like this works just fine:

<form action="index.htm" method="post" tmt:validate="true" onsubmit="return doThis()">

The only requirement is that the function/s that get called by the onsubmit event always return a boolean. If the code doesn't return any value or something that can’t be converted to a boolean, the TMT Validator will never be triggered because it assumes that the previous functions returned false and form submission will be stopped.

Please note the validator will be executed last, after evaluation any other code already attached to the onsubmit event.

Filters don't work

Filters are attached to the fields as soon as the page loads. They don't work on form fields that are added at run-time. In order to enable filters, the tmt:validate attribute of the <form> tag must be set to true

Namespaces and Gecko based browsers

If you are serving your pages using an XML mime-type, and you are getting this weird error from the most recent versions of Gecko based browsers:

XML Parsing Error: prefix not bound to a namespace

...all you need to do is to add the proper namespace declaration inside the <html> tag:

<html xmlns:tmt="http://www.massimocorner.com/libraries/" xmlns="http://www.w3.org/1999/xhtml">

Compatibilty with Prototype

Older versions of the Prototype JavaScript library may cause conflicts with the TMT Validator (especially if you are validation radio buttons and check boxes). Please note this is this is due to issues inside the Prototype library, not the TMT Validator (see here for additional details). As far as I know the issues were solved starting with version 1.5 of the Prototype library. Results with older versions may vary.