I want to set up the validation of a postcode field in a question. I have added a few languages but I can see that this field is common to all of them. Where the postcode differs from country.
Try to combine the language and the validation of postcode in your question validation.
The language is stored in the variable {LANG},
Something like (LANG=='de' AND regexMatch('/^\d{5}$/',self)) OR (LANG=='nl' AND regexMatch('/^\d{4}[A-Z]{2}$/',self)) OR ...
And for the validation tip there are all languages available.
But maybe it is better not to make it dependent on the language, but from the country.
So instaed of "LANG=='en'" something like "Q1==1", if "1" was the code of the country in question "Q1".
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
I was surprised that in the table "Questions" it creates a new row when adding the language version, but the column "preg" is common to both, e.t. other attributes from the core (main category)
But now he understands that it is actually better to use "em_validation_q" instead of "preg" for this as I can define error messages.
In fact, it would be better to add a country to the form if the fields are to be validated against the country.
alorenc wrote: In fact, it would be better to add a country to the form if the fields are to be validated against the country.
No,
Because a large majority of usage are : same condition for all language but tips different for each language.
If you different confdition for each language :
More complex for a large majority of user
More complex for developper (mean more bug)
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. -
Professional support
-
Plugins, theme and development
. I don't answer to private message.
I don't think adding a country column makes sense. The next one comes and wants a "organization" column and the next one, and the next one.
Already the various languages can make things quite complicated.
So either you write your validation accordingly considering the country (which can be quite different from language, just like Joffm mentioned) or you use copies of the survey for each country, which sometimes might actually the best and cleanest way to do it.
Help us to help you!
Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.