Dear Devs,
Maybe I missed something in V4. How can I use Auto server-side validation option AND Custom server-side validation simultaneously. I can't figure out how to do that on submit action?
I'd like to put the extra layer of spam/security to the fields by adding validation for the HTML tags. The code should be like:
Also, is there an option to put an extra JS validation options to the standard validation options of the fields without hacking the core files?
Maybe I missed something in V4. How can I use Auto server-side validation option AND Custom server-side validation simultaneously. I can't figure out how to do that on submit action?
I'd like to put the extra layer of spam/security to the fields by adding validation for the HTML tags. The code should be like:
if (!preg_match("/^[^<>]+$/",$_POST['input_textarea_6'])){
return 'Enter plain text';
}
Also, is there an option to put an extra JS validation options to the standard validation options of the fields without hacking the core files?
Hi guimplenchik,
You can drag both actions into the On Submit box one after the other.
There's an example of a custom validation in this post
Bob
You can drag both actions into the On Submit box one after the other.
There's an example of a custom validation in this post
Bob
Thank you for the quick reply. Now seems like everything is working fine.
I put the Custom Server Validation block with code first and with empty OnSuccess block. Than I dragged the Auto Server validation block.
Seems like the Custom server-side check is also have changed and my code should look like this:
For JS validation:
Than, I've put the extra validation class with %-sign into the form's code:
Thanks again..
I put the Custom Server Validation block with code first and with empty OnSuccess block. Than I dragged the Auto Server validation block.
Seems like the Custom server-side check is also have changed and my code should look like this:
<?php
// No HTML tags allowed
//// plain text
if (!preg_match("/^[^<>]+$/",$_POST['input_text_0'])){
$mainframe =& JFactory::getApplication();
$mainframe->enqueuemessage('Please enter a plain text without tags');
return false;
}
?>
For JS validation:
function checkHTML(element){
if (!element.value.test(/^[^<>]+$/)) {
element.errors.push("Please enter a plain text without tags");
return false;
} else {
return true;
}
}
Than, I've put the extra validation class with %-sign into the form's code:
class= "validate['required','%checkHTML']"
Thanks again..
Hi guimplenchik,
The 'official' ChronoForm error messages use
You can also use the Joomla! system messages if you prefer. It might be worth marking them as errors
Bob
The 'official' ChronoForm error messages use
$form->validation_errors['input_text_0'] = "Please enter a plain text without tags.";.
(From the help tab) They show a message by the input as well as at the top of the page.You can also use the Joomla! system messages if you prefer. It might be worth marking them as errors
$mainframe->enqueuemessage('Please enter a plain text without tags', 'error');
Bob
This topic is locked and no more replies can be posted.