Hello,
I would like to perform some custom validations with ChronoForms v5.
I am willing to buy a good manual or even faq.
The first validation is to check if a username is valid.
The other is to check whether an integer that is entered is 11digits length. I do not have much experience with JavaScript so this is the code that I have created to do that. Can somebody help?
Thanks a lot.
I would like to perform some custom validations with ChronoForms v5.
I am willing to buy a good manual or even faq.
The first validation is to check if a username is valid.
The other is to check whether an integer that is entered is 11digits length. I do not have much experience with JavaScript so this is the code that I have created to do that. Can somebody help?
function customCheck(number11){
if ( !number11.value.test.length()!=11) {
el.errors.push("Your number must be 11 digits");
return false;
} else {
return true;
}
}
Thanks a lot.
Hi hellykun,
Please check the custom validation box info under the validation tab in v5 rc4.1, its explained how to write a custom function in v5, you can then write your function name there and it will be used.
Regards,
Max
Please check the custom validation box info under the validation tab in v5 rc4.1, its explained how to write a custom function in v5, you can then write your function name there and it will be used.
Regards,
Max
Ok just something simpler.
I have created a filed number for example.
I have added as customValidation with the name "customCheck"
Then in the onload Event before everything else I have added a Load Javascript block.
Inside the block I have added my function:
Am I doing something wrong? Nothing different happened.
Thanks a lot in advance.
I have created a filed number for example.
I have added as customValidation with the name "customCheck"
Then in the onload Event before everything else I have added a Load Javascript block.
Inside the block I have added my function:
function customCheck(number){
if (number < 20) {
return false;
} else {
return true;
}
}
Am I doing something wrong? Nothing different happened.
Thanks a lot in advance.
Hi hellykun,
I think that what is passed to the custom function is the whole form element, not just it's value (see Max's example). Try changing your code to
Bob
I think that what is passed to the custom function is the whole form element, not just it's value (see Max's example). Try changing your code to
if (number.value < 20) {
or possibleif (parseInt(number.value) < 20) {
to force it to an integer instead of a string.
Bob
Thanks a lot GreyHead.
The problem was not only that but the el.push.message is not receiving the correct message so I thought it was not registering at all.
Is there a way of adding custom PHP Server validation to Chronoforms V5. It is not possible for me to go to V4 only for this feature. Can I change a specific php file to achieve this?
Thanks a lot.
The problem was not only that but the el.push.message is not receiving the correct message so I thought it was not registering at all.
Is there a way of adding custom PHP Server validation to Chronoforms V5. It is not possible for me to go to V4 only for this feature. Can I change a specific php file to achieve this?
Thanks a lot.
HI hellykun,
I'm afraid that so far I know nothing about the CFv5 code and what can (or can't) be changed :-(
Bob
I'm afraid that so far I know nothing about the CFv5 code and what can (or can't) be changed :-(
Bob
Hi,
The code above is a javascript validation, if you need php server validation then simply use the "server side validation" action for auto validation, or the "Event switcher" action for custom stuff.
Regards,
Max
The code above is a javascript validation, if you need php server validation then simply use the "server side validation" action for auto validation, or the "Event switcher" action for custom stuff.
Regards,
Max
Thanks a lot.
Is there a guide on how to use the Event Swicher action because it is not so straightforward for me?
Because the validation I want to use is more complex than the predifined values of Server Side Validation.
Thanks a lot again.
Is there a guide on how to use the Event Swicher action because it is not so straightforward for me?
Because the validation I want to use is more complex than the predifined values of Server Side Validation.
Thanks a lot again.
Hi hellykun,
It's easy to use, just write your PHP code and make it return a string matching the event name you need to process, so suppose that you have 1 event in the event switcher called "test", then the code below will execute this event:
Regards,
Max
It's easy to use, just write your PHP code and make it return a string matching the event name you need to process, so suppose that you have 1 event in the event switcher called "test", then the code below will execute this event:
<?php
if(true){
return "test";
}
Regards,
Max
Thanks a lot admin, so how can I return stop submission of the form and show a message?
return false?
return false?
Just in case I would be nice if you can add a step by step tutorial for creating custom validation with php code because it is of high importance. If I succeed I will post it.
We will try to add more FAQs soon!
You can simply return "stop", and drag a "Show stopper" action in the "stop" event created using the "Event switcher".
Before that "show stopper" you may also add a "thanks message" action.
Regards,
Max
You can simply return "stop", and drag a "Show stopper" action in the "stop" event created using the "Event switcher".
Before that "show stopper" you may also add a "thanks message" action.
Regards,
Max
Thanks a lot admin!
I have added a custom validation rule by changing both chronoforms and joomla php files because it seemed easier to me.
I have added a custom validation rule by changing both chronoforms and joomla php files because it seemed easier to me.
That's not a good idea, you will lose these changes when you updates either Joomla or Chronoforms, and the updates are important sometimes!
Regards,
Max
Regards,
Max
This topic is locked and no more replies can be posted.