0

I'm using Zend Form and the Jquery form validation plugin (http://bassistance.de/jquery-plugins/jquery-plugin-validation/). However, the plugin gets the required fields in the input tag. So for example, it locates "< input type='text' class='Required' id='anything' >" to perform the validate method. However, in Zend Form, when I use the setRequired(true) function, it places the "class='required'" inside the label portion. How do I resolve this?

PLUGIN < label >Hey< /label > < input type='text' class='Required' id='anything' > WORKS!

ZEND < label class='Required'>Sup < input type='text' id='anything' > DOES NOT WORK!

3
  • I think that jQuery data validation plugin can be restricting at times. I've had issues similar to this because it does a lot for you. I ended up writing my own Validation library that gives me more control while still producing custom errors. However, the DOM manipulation is left up to you. github.com/skaterdav85/Validator.js Commented Mar 13, 2013 at 2:12
  • You already know the answer. Put it where the plugin needs it. Extra class inside the label will not interfere with the plugin. Commented Mar 13, 2013 at 5:09
  • Zend code is for "server-side" validation. jQuery code is for "client-side" validation. These are two different things so you cannot expect the settings for one to affect the other. Just give each method its required setups and both can work independently. Zend Validation will simply take over if/when jQuery Validation fails. Commented Mar 13, 2013 at 14:14

1 Answer 1

0

You need something like this

$anything = new Zend_Form_Element_Text('anything');
$anything->setLabel('Label')
   ->setRequired(true)
   ->setAttrib('class', 'required');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.