Forum


Calc Builder Support

Calc Builder support
Forums
Public write access is disabled. Please login

Validate date 12.05.2015 15:54

Me again - I apologize for the number of threads...

Some issues about dates:

1. How can I set Down Limit in date fields to "Today"? I know how to do that with JS but maybe there's a default function...?

2. Is there a way to validate dates or do I have to write my own script? (You can type in sth. like 44.03.2015 without getting an error)

3. How can I throw a custom CB error via JS?

4. Do you provide a documentation of integrated JS functions?

Best regards

Alex

Re: Validate date 13.05.2015 08:52

Hi,
javascript that can be used at the calculator is all valid jQuery/jQueryui, so there is not an own guide, apart from some helpers that we have added and you can see at the left of the code area. For ex, if you want to check which are the functions regarding calendar, there are official docs and examples here:


https://jqueryui.com/datepicker/#min-max

there you can check how to add limits, for ex, minimum date=today for a field with var= mydatefield

CB("input[fldname=mydatefield]").datepicker({ minDate: 0});


For validation, we use the jquery validation plugin
(http://jqueryvalidation.org/)

we have some validations already included, and you can also include your own. Please check the js file
mod_calcbuilder/assets/js/validation.js

there you can check how to build a custom validation and show messages, like the last one at the bottom of the file (validate combobox, other option different from the first one must be selected to be valid).

So, if at fields config you set the css class of one option field as 'cb_option_non_first' it will automatically attach this validation to that field.

Once you have attached one validation to a field, the error message and the error style are shown when form is submitted, or, if with js the 'error' class is set to that field:

CB("input[fldname=myfield]").addClass("error");

Hope this helps, regards
Moonsoft Team
www.moonsoft.es
Are you satisfied with our products/services/support?
Please help us to keep improving, add a review at  joomla extensions site and  magento connect

Our clients' feedback