tags:

views:

65

answers:

1

I have a problem to use jquery Plugin/Validation.

I want to add a method and follow the documentation but I think I still missing some thing.

First I add the method but I think I have a problem to implement it.

please check my code and advice me.

   <script src="js/jquery-1.4.1.js" type="text/javascript"></script>

    <script src="js/jquery.validate.js" type="text/javascript"></script>


    <script type="text/javascript">



        $(document).ready(function() {

        jQuery.validator.addMethod("domain", function(value, element) {
            return this.optional(element) || /^http:\/\/yahoo.com/.test(value);
        }, "Please specify the correct domain for your documents");



            $("#aspForm").validate();
        });

   <asp:TextBox ID="TextBox1" runat="server" CssClass="domain" ></asp:TextBox>


</script>
A: 

I was able to find the right code for how to implement validation rule: here is the code:

<script src="js/jquery-1.4.1.js" type="text/javascript"></script>

    <script src="js/jquery.validate.js" type="text/javascript"></script>


    <script type="text/javascript">


   //Our validation script will go here.
        $(document).ready(function() {

           jQuery.validator.addMethod("domain", function(value, element) {
            return this.optional(element) || /^http:\/\/yahoo.com/.test(value);
        }, "Please specify the correct domain for your documents");





            //validation implementation will go here.
            $("#aspnetForm").validate({
                rules: {
                    "<%=TextBox1.UniqueID %>": {

                        domain: true
                    }
                }

            });
        })

</script>

Eyla