1

I have two field like this,

<tr>
    <td align="right"><b>Min Capacity:</b></td>
    <td><input type="text" name="cbbMinCap" value="" class="validate[custom[integer],required,minSize[1], maxSize[4]] text-input"/></td>
</tr>
<tr>
    <td align="right"><b>Max Capacity:</b></td>
    <td><input type="text" name="cbbMaxCap" value="" class="validate[custom[integer],required,minSize[1], maxSize[4]] text-input"/></td>
</tr>

My goal is to validate Min Capacity < Max Capacity. I checked in jquery.ValidationEngine.js but can't found it. Please help me.

2 Answers 2

2

You can use custom validation

i have given full codes now

<script type="text/javascript">
    jQuery.validator.addMethod("lessthan", function(value, element, params) {
                    return this.optional(element) || value <$(params).val();
      }, jQuery.validator.format("Please enter the correct values"));

    jQuery(document).ready(function(){
           $("form").validate({
              rules: {

                    cbbMaxCap: {
                                required:true,
                                lessthan: "#cbbMinCap"// this is id you want to compare tp this input
                                },
                    cbbMinCap:{

                            required:true,
                        },  
              }
            });

    });
 </script> 

for input fields give a id (or class)

<input type="text" name="cbbMinCap" value="" class="" id="cbbMinCap"/>
<input type="text" name="cbbMaxCap" value="" class="" id="cbbMaxCap"/>

you can use validation engine from http://jqueryvalidation.org

Sign up to request clarification or add additional context in comments.

1 Comment

ah,where should I put it in.I have posted the code below. Please forgive my stupidity
2

you can use your own validations

see http://jqueryvalidation.org/jQuery.validator.addMethod/

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.