In my contactform I want to display a inputfield, that may only contain a number, higher than 5.

How can I achieve that?

My current code is:

            <div class="field">
            <label for="gewensteaantal" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Requested qty') ?></label>
            <div class="input-box">
                <input name="gewensteaantal" id="gewensteaantal" title="<?php echo Mage::helper('contacts')->__('Requested qty') ?>" value="" class="input-text required-entry" type="text" />
  • higher than 5 digits or higher than 5 ie (6, 7 and so on ) ? Commented Aug 11, 2016 at 7:24

3 Answers 3


You can use custom validation class 'validate-value-greater-than-5' and add following script in form javascript.

Validation.add('validate-value-greater-than-5', 'Please enter a value greater than 5.', function(v) {
    return Validation.get('IsEmpty').test(v) || (v > 5);

You have to just use type=number in input.

 <input type="number" name="quantity" min="6">

Now user have input 6 or higher than 6 to submit form otherwise display error with no form submit.


Use this class :

class="input-text validate-length maximum-length-50 minimum-length-5 validate-greater-than-zero validate-number validate-digits required-entry"

This will accept only digits and numbers with minimum of 5 and maximum of 50 length

These classes "validate-length maximum-length-50 minimum-length-5" are responsilble to handle the max and min length

  • Thanks, but that does not work. The minimum length should be 5. Which is not the number, but the characters. So than a number must be at least a 5 digit number.
    – JGeer
    Commented Aug 11, 2016 at 8:27

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.