Note that there are some explanatory texts on larger screens.

plurals
  1. POInvalid Zend_Validate_Float
    primarykey
    data
    text
    <p>I am using the Float validation, to validate the data on my Zend_Form field.</p> <p>But the behavior of validation is something that is of concern.</p> <p>It validates correctly, if the form is posted through Firefox or Chrome, but it says invalid when used through IE.</p> <p>With IE, it validates any value greater 10, i.e. greater than 10.00, but says invalid if the value is lower than 10.00</p> <p>There has been no locale defined for the form, so i guess it would take default as <code>en</code>.</p> <p>I understand the validation are something that works on server-side and the client interface should not make an impact, but it still seems to be so.</p> <p><strong>Form Class :</strong></p> <pre><code>class Application_Form_Custom extends Zend_Form { public function init() { $this-&gt;setMethod('post'); $this-&gt;setName('form_custom'); $this-&gt;setElementFilters(array('StringTrim','StripTags')); $notEmpty = new Zend_Validate_NotEmpty(); $notEmpty-&gt;setMessage('Value is required', 'isEmpty'); $valid_float = new Zend_Validate_Float(); $valid_float -&gt; setMessages(array( 'floatInvalid' =&gt; 'Invalid', 'notFloat' =&gt; 'Invalid' )); $deposit = new Zend_Form_Element_Text(array( 'name' =&gt; 'txtDeposit', 'style' =&gt; 'width:99%;', 'autocomplete' =&gt; 'off' )); $deposit -&gt; setLabel('Deposit : '); $deposit -&gt; setValue('0.00'); $deposit -&gt; setRequired(true); $deposit -&gt; addValidators(array(array( $notEmpty, true ), array( $valid_float, true ))); $submit = new Zend_Form_Element_Submit('btnSubmit'); $submit -&gt; setLabel('Submit'); $reset = new Zend_Form_Element_Reset('btnReset'); $reset -&gt; setLabel('Reset'); $this-&gt;addElements(array( $deposit, $submit, $reset )); } } </code></pre> <p><strong>Controller:</strong></p> <pre><code>class FormsController extends Zend_Controller_Action { public function customFormAction() { $form= new Application_Form_Custom(); if ($this-&gt;getRequest()-&gt;isPost() &amp;&amp; $form-&gt;isValid($this-&gt;_request-&gt;getPost())) { ///...blah...blah...about my process } $this-&gt;view-&gt;form =$form; } } </code></pre> <p><strong>View :</strong></p> <pre><code>&lt;form id="&lt;?php echo $this-&gt;form-&gt;getName(); ?&gt;" name="&lt;?php echo $this-&gt;form-&gt;getName(); ?&gt;" action="" method="&lt;?php echo $this-&gt;form-&gt;getMethod(); ?&gt;"&gt; &lt;table width="100%" border="0" cellpadding="4" cellspacing="0"&gt; &lt;tr&gt; &lt;td align="left" valign="top" nowrap="nowrap"&gt;Deposit&lt;/td&gt; &lt;td&gt;&lt;?php echo $this-&gt;form-&gt;txtDeposit-&gt;renderViewHelper(); if(count($this-&gt;form-&gt;txtDeposit-&gt;getMessages()) &gt; 0) { ?&gt;&lt;br /&gt; &lt;div style="color:#F00;"&gt; &lt;?php $i=0; foreach($this-&gt;form-&gt;txtDeposit-&gt;getMessages() as $msg) { echo $msg; $i++; if(count($this-&gt;form-&gt;txtDeposit-&gt;getMessages())&gt;$i) { echo '&lt;br /&gt;'; } } ?&gt; &lt;/div&gt; &lt;?php } ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr align="left" valign="top"&gt; &lt;td colspan="2" align="center" nowrap="nowrap"&gt;&lt;?php echo $this-&gt;form-&gt;btnSubmit-&gt;renderViewHelper(); ?&gt; &lt;?php echo $this-&gt;form-&gt;btnReset-&gt;renderViewHelper(); ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload