Hi. I'm doing a form at my website, and I found this document which is very interesting: Javascript form validation - doing it right .
I have a little question though. All the documents within my page has the *.php extention since I'm using PHP the most. I'm also using gettext to translate strings to other languages. If I want to translate the string "hello", I would write it like this in my *.php document:
In my navigation bar, I have links to different languages. Pressing one of these links sets a global variable that gettext uses to identify what language that's active and then translates all the strings which are marked in same way as the code above..
I encounter a problem when mixing this JavaScript code with my PHP code. Because I want the output messages from the validation to be translated as well. For instance if a field is left blank the JavaScript outputs the message: "Required field cannot be left blank". I want this message to be translated as well.
So what is the best strategy here? Should I do it all in PHP? Does anyone have experience with this kind of setup? Thanks in advance.
Regards
I have a little question though. All the documents within my page has the *.php extention since I'm using PHP the most. I'm also using gettext to translate strings to other languages. If I want to translate the string "hello", I would write it like this in my *.php document:
Code:
<?php echo _("hello");?>
I encounter a problem when mixing this JavaScript code with my PHP code. Because I want the output messages from the validation to be translated as well. For instance if a field is left blank the JavaScript outputs the message: "Required field cannot be left blank". I want this message to be translated as well.
So what is the best strategy here? Should I do it all in PHP? Does anyone have experience with this kind of setup? Thanks in advance.
Regards
Comment