jQuery Validate Not Working

后端 未结 1 371
遥遥无期
遥遥无期 2021-01-28 07:27

I have an issue with my code it seems the .validate is not working but all the documents are connected and working sweet:

HTML:

<         


        
相关标签:
1条回答
  • 2021-01-28 07:54

    Your code, as you've posted it, is working as expected... jsFiddle DEMO

    Regarding your code...

    jQuery(document).ready(function() { 
        //Home Validation
        $("#quote").validate({
            rules:{
                companyName:{
                    required: true,
                    url: true
                }
            }
        });
    });
    

    If you've put jQuery into noConflict mode, then your code in noConflict mode is broken.

    When using noConflict mode, you must pass the $ symbol into the document.ready function. Working demo...

    $.noConflict();
    jQuery(document).ready(function($) {
        $("#quote").validate({
            // rules
        });
    });
    

    OR, you'd use jQuery in place of $ everywhere. Working demo...

    $.noConflict();
    jQuery(document).ready(function() { 
        jQuery("#quote").validate({
            // rules
        });
    });
    

    Otherwise, without using no-conflict mode, it would just look like this. Working demo...

    $(document).ready(function() {
        $("#quote").validate({
            // rules
        });
    });
    
    0 讨论(0)
提交回复
热议问题