I have seen the tutorial http://www.chronoengine.com/faqs/2622-my-alphabet-uses-characters-other-than-a-z---.html but i have some questions...
I have made the form and i have added at all my fields the type of validation i wanted. Then i created the events i wanted and the form was working properly. Finally i saw that Tutorial and i added a "Custom server Side Validation "
I used the code with many regex expressions but none worked. Like not even seeing that php. Shall i change anything else ??
The only thing i want is to make the validation accept one more alphabet. Is there a better way ??
Is there something else i shall do ?
Provided that your regex does what you want and the Custom Serverside Validation action is correctly set up there is nothing else required.
What alphabet are you checking and what code do you have in the action?
Bob
<?php
$data =& $form->data['input_name'];
$regex = '\p{InGreek}';
if ( isset($data) && $data ) {
if ( preg_match($regex, $data) === false ) {
$form->validation_errors['input_name'] = "Invalid data";
return false;
}
}
?>
A bit of research required but this version seems to work OK
<?php
$data =& $form->data['input_text_1'];
$regex = '/\A\p{Greek}+\Z/iu';
if ( isset($data) && $data ) {
if ( preg_match($regex, $data) === 0 ) {
$form->validation_errors['input_text_1'] = "Invalid data";
return false;
}
}
?>This has a different regex from yours and critically the test is === 0 NB === false won't work here, I got that wrong in the FAQ :-( It is now corrected. (false is returned if there is an error in the test, zero is returned if there is no match.
This passes 'ολκκ' and fails 'abde'
Bob
Shall i replace "input_text_1" with the field name i want to validate?
Shall i disable the Validation from the element?
How can i let pass both greek and english ?
The Action is not seems to working can you please check it ?
I have, it works OK.Shall i replace "input_text_1" with the field name i want to validate?
YesShall i disable the Validation from the element?
No, you don't need to.How can i let pass both greek and english ?
Change the regex to allow both, and numbers, . . .Bob
You can see a copy of your form here with the serverside validation working OK. I copied the code from this thread and changed 'input_name' to 'name' to match your form.
Do you have an Event Loop in he On Fail event of the Custom Serverside Validation action?
Bob
But the form you have copied has exactly the same problem with mine!
If you add at first field greek chars like "τεστ" and fill in all others in english just to test you will see that the validation will pop up an error at the first field that accepts only alphabetic characters. That shows that the validation with greek chars is not working but i would like if it works to work with both english and greek.
My problem was that from the beggining and sorry if my english were bad.
I'm sorry I do not understand what you are saying here. You asked for Serverside validation for Greek characters and that is working on my test form with the code I have posted here.
If you want both Greek and English characters then you will need to change the regex to accept both.
Bob
You will see that the Serverside validation for greek is not working. It does not accept greek chars
Hi webbuilders,
I'm sorry I do not understand what you are saying here. You asked for Serverside validation for Greek characters and that is working on my test form with the code I have posted here.
If you want both Greek and English characters then you will need to change the regex to accept both.
Bob
Ah OK. That's the Client side validation - I've removed it now.
Bob
Now how can i add at the fields to be "Required" if at your example i press Submit at empty form then the form is sent empty.
Hmmm . . . that would be because I removed the Client side validation so that you could see the Serverside validation is working.
As I said before you probably need both. Client Side Validation helps the user complete the form correctly. Serverside Validation validates (and possibly cleans) the submitted data to make sure that you have valid and save data to work with.
Bob
CAn you enable both server and client side validation and see if the form works properly ?
