Loading...
 
Tiki and PluginR

Tiki and PluginR


Numerical Field validation in Prettytracker to execute R code

posts: 14 SPAIN

Hi all,

I'd need to add a restriction in a numerical field from a tracker but I don't find the way...

In particular, I have some fields corresponding to probabilities, so I'd need some kind of warning in case the user enter a negative value (or higher than 1).

I've tried using Jquery, but I failed cry
http://doc.tiki.org/PluginJq#Conditional_display_of_fields

Also, with "PluginTrackerIf"...

Is there any "easy way" to add a restriction validation for a numerical variable?

Thanks!

Moisés

posts: 1817 Catalan Countries

Hi Moisés:

I would suggest that you try the validation feature, already implemented in Tracker fields:

https://doc.tiki.org/Tracker+Field+Validation

You can create your own validation methods, it seems, as documented there, or use the regexp validation type, so that you can use your own regular expression there, without creating any new php file, etc.

Unfortunately, I'm not that good at regular expressions, but I bet that it's the besst approach for waht you want to achieve.

If you want to share some examples for your case, once you know how to do it, you can update this page:

https://doc.tiki.org/Regexps

Cheers

posts: 14 SPAIN

Solved!

Thank you Xavi. Using a regular expression it works perfectly:

Copy to clipboard
^((0(\.[0-9]*)?)|(1(\.0)?))$


I've posted an example in the page you've mentioned:
https://doc.tiki.org/Regexps

Hope this helps other tiki-people, hahaha

Cheers

Moisés

posts: 1817 Catalan Countries

Great! thanks also to you for updating that doc page! :-)
Cheers
Xavi