Client-side validations

Client-side validations

  
Recently I had a problem related to client-side validations made by the platform. On this case, it was triggered by a platform upgrade (3.1 -> 4.0) because validations are made in different ways between these releases.
Anyhow, this problem may occur out of the scope of an upgrade, so it may be useful sharing this.

Scenario:

- Mandatory fields, including a currency field (bound to a variable of type Currency).

- Submit button (Client & Server Validation) with an onclick handler (ext. properties). This handler was in the form:

"onclick" = "return MyValidation();".

After 1-CP, the button is actually rendered as:

<input onclick="return MyValidation();OsPage_ClientValidate('wtButtonSave');" (...)

As you can see, platform code is appended to our handler. Due to the unconditional return statement, the platform scripts are never executed when clicking the button... One of the symptoms was related to the decimal separator not being replaced in the currency field (',' by '.'), which was originating errors.

Solution:

Simply modify the onclick handler so that on a 'submit ok' scenario the platform scripts are not broken by our code:

"onclick" = "if (!MyValidation()) return false;"



Credits to Miguel Melo / Rodrigo Coutinho for identifying the problem.

Cheers,
Paulo Ramos

This was VERY VERY USEFUL!! THANKS A LOT!!