Developer forum

Forum » CMS - Standard features » Client side validations

Client side validations

Adrian Ursu
Reply

Hi Guys,

Since a lot of the form validations should be done client-side (new account, edit account, edit password, etc) I need to have access to Translated tags inside Javascript.

Some modules (like Extranet module) have their own section of error messages. Unfortunately I could not find a way to access those strings when the errors are not happening.

Keeping the strings in the module and not using them is confusing for the admin, moving the Errror messages in Translations will make them unavailable in Javascript.

What would be a good recommendation for implementation in this case? 

Thanks,
Adrian

 


Replies

 
Nicolai Høeg Pedersen
Reply

Hi Adrian

I'm not sure i understand your question fully. It is correct, that you cannot access the error messages made from server side validation from JS.

You can, however, use translates in javascript

<script>

var message = '<!--@Translate(WrongUserNameOrPassword, "Wrong username or password")-->';

//run validation and display message

</script>

 
Adrian Ursu
Reply

That's great!

I didn't know we can insert Translate into javascript directly.

Thanks a lot.

Adrian

 
Adrian Ursu
Reply

Your example shows how to use translation in a script in page.

How about using the Translate in an external Javascript? Is it possible?

 
Nicolai Høeg Pedersen
Reply

Hi Adrian

You would then do like this

<script>

var message = '<!--@Translate(WrongUserNameOrPassword, "Wrong username or password")-->';

</script>
<script src="externalValidation.js"></script>

Then inside the externalValidation.js use that variable.

NP

<script>

var message = '<!--@Translate(WrongUserNameOrPassword, "Wrong username or password")-->';

//run validation and display message

</script>

- See more at: http://developer.dynamicweb.com/forum/cms-standard-features.aspx?ThreadID=44663#sthash.A8T2ck6Z.dpuf
 
Adrian Ursu
Reply

Yes. That's how we did it.
But for the client it look like we override the system. We teach the client to use the seetings on modules, they see the validation messages in there but we cannot use them.

We have to explain that the messages are in a different place and they have to be maintened separately...

In my opinion all these workarounds are not looking good for the customer. Maybe I am wrong about it.

Thanks,

Adrian

 

You must be logged in to post in the forum