-4

I want to use both form validation as well as datepicker in html. Because of conflict its not working. Please help. Here is my code.

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"                          type="text/javascript"></script>
    <script     src="http://ajax.microsoft.com/ajax/jquery.validate/1.5.5/jquery.validate.js"     type="text/javascript"></script>
    <script type="text/javascript">

     $().ready(function() {  
     $("#form1").validate({  
      rules: {  
          asset_name: 'required',  
          asset_code: 'required',  
          asset_desc: 'required',  
          purchase_date: 'required'  


         }
        });
       });  
       </script>
       <link rel="stylesheet"      href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" />
       <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
        <script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
        <link rel="stylesheet" href="/resources/demos/style.css" />
       <script type="text/javascript">  
       jQuery.noConflict();  
       $(function() {  
       $( "#purchase_date" ).datepicker({ dateFormat: 'yy-mm-dd' });  
        });  
           $(function() {  
      $( "#renewal_date" ).datepicker({ dateFormat: 'yy-mm-dd' });  
      })(jQuery);  
          </script>
jayant kumar
  • 333
  • 2
  • 4
  • 11

2 Answers2

1

you can use .noConflict() for this

<!-- load jQuery 1_8_3 -->
    <script  src="../assets/js/jquery-1.8.3.min.js"></script> 
        <script type="text/javascript">
        var jQuery_1_8_3 = $.noConflict(true);
        </script>

        <!-- load jQuery 1.4.2 -->
        <script type="text/javascript" src="jquery/jquery-1.4.2.js"></script>
        <script type="text/javascript">
        var jQuery_1_4_2= $.noConflict(true);
        </script>

see here

Community
  • 1
  • 1
PSR
  • 39,804
  • 41
  • 111
  • 151
0

Try using:

jQuery.noConflict();

You will find an example and documentation here.

Prasad Jadhav
  • 5,090
  • 16
  • 62
  • 80