Problems, need help? Have a tip or advice? Post it here.
4 posts Page 1 of 1
I have the following question:

I have a field, that is not required in the form, but i do want to validate it. SO here is the code for the field
Code: Select all
<cms:input name='qty1' id='qty1' type='text' search_type='decimal' validator='non_negative_decimal' placeholder="Quantity" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Quantity'" validator_msg='required:Please enter valid quantity'  />


the form doesn't submit but at the same time the validator_msg is not showing anywhere.
I also tried the <cms:show validator_msg /> but still no success.
The message you wish to show is tied up with 'non_negative_decimal' validator (and not 'required') so the code should be as follows -
<cms:input
name='qty1'
type='text'
search_type='decimal'
validator='non_negative_decimal'
validator_msg='non_negative_decimal=Please enter valid quantity' />

Please also notice that I've used '=' (and not ':') in the expression.

Does this help?
I Pasted this code, but the validation error didn't show up.
How do i show the validation error (may be I forgot to enter the code to show the error)
Following test works for me -
Code: Select all
<cms:form method='post' anchor='0'>

    <cms:if k_error>
        <h3><cms:show k_error /></h3>
    </cms:if>

    <cms:input
        name='qty1'
        type='text'
        search_type='decimal'
        validator='non_negative_decimal'
        validator_msg='non_negative_decimal=Please enter valid quantity' /> 

    <cms:input name='submit' type='submit' value='Submit' />
</cms:form>

Please see docs (http://www.couchcms.com/docs/concepts/forms.html) for more on this subject.
4 posts Page 1 of 1