CalcBuilder Forum

Validate date

User moon_1859 2015-05-12 15:54:00

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


Moonsoft support 2015-05-13 08:52:25

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:

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

CB("input").datepicker({ minDate: 0});

For validation, we use the jquery validation plugin

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

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:


Hope this helps, regards


Perfect for small code changes or to correct any bug at your site

Buy now!
Support/development 40 hours

With the peace of mind of having a professional team at your service (20% discount)

Buy now!