views:

234

answers:

4

Hi, i have a problem trying to validate something. I hope you can help me! IM USING STRUTS2

"currentTarjeta.causaDeUnicoServicioContratado": {
required: "#currentTarjeta.causaDeUnicoServicioContratado:checked",

i need to validate input "currentTarjeta.causaDeUnicoServicioContratado" when is checked the check "currentTarjeta.causaDeUnicoServicioContratado".

the problem is that i need this odd name "currentTarjeta.causaDeUnicoServicioContratado" because if i use "something" as the name this works. Damn dot!

Pliss!!

+1  A: 

That is exactly the problem. The dot assumes a css class name. How about using an underscore or a dash instead of a dot in the name.

ichiban
A: 

Thanks ichiban for the response

...but im working with Struts2 and i need the point to get the attribute from the object.

y use someObject.someProperty="xyz" and in my Action i easily get the value doing nothing.

Any other idea?

orlandoMG
A: 

Well i kinda find a solution.

I use named my tag name="man.name" and y use de id attribute id=name.

So when i use the validate function i call de id and not the name:

required: "#name:checked"

and this works :)

orlandoMG
+2  A: 

Escape the dot using "\\"

Example:

 // Instead of
 $("#something.id")

 // Write
 $("#something\\.id")

It will work :)

Mohamed ElSheikh
the reason you need 2 backslashes is that the first one is interpreted by Javascript, and the next one is interpreted by JQuery.
DDaviesBrackett