Ujwal Khairnar Ujwal Khairnar - 4 months ago 63
Javascript Question

How to use jQuery plugins (jquery validation engine) with OpenUI5/SAPUI5?

I want use jquery validaton engine in SAPUI5. Please guide me, I have done following steps.


  1. Added jquery library

  2. Added jquery validation library and css.

  3. Give a validate[required] class to input text field.

  4. on button click called
    $("#empform").validationEngine();
    function.

  5. But it is give me TypeError: $(...).validationEngine is not a function error.


Answer

jQuery is already part of the SAPUI5 distribution. So if you load SAPUI5 after including your custom jQuery + jQuery validation engine you will just end up with the plain jQuery version bundled with SAPUI5.

You can either load jQuery validation engine after SAPUI5 or use the no-jquery SAPUI5 variant as follows:

<script id="sap-ui-bootstrap"            
        src="resources/sap-ui-core-nojQuery.js" 
        data-sap-ui-libs="sap.m"
        data-sap-ui-theme="sap_bluecrystal">
</script>