Hi Team
I am unable to register new users, due to this issue to my js file. How do i resolve this issue? I have the correct js library. Let me share my logic below;
// register.js
(function($) {
$.fn.registerMessage = function(message, type) {
// create a new element to display the message
var messageElem = $('', {
class: 'register-messages ' + type,
text: message
});
// append the message element to the div card
$('#registration-messages').html(messageElem);
// set a timeout to remove the message element after 5 seconds
setTimeout(function() {
messageElem.remove();
}, 5000);
};
})
// html code
Tuhin PaulPosted May 3, 2023, 6:47 PM
I think you are trying to use the registerMessage function defined in register.js, but it has been wrapped inside an immediately invoked function expression (IIFE), which means it is only accessible within its own scope. To fix this issue, move the $(document).ready() block outside of the IIFE so that it can access the registerMessage function properly.
Tuhin PaulPosted May 3, 2023, 6:45 PM
Based on the code you provided, it seems that the issue might be related to the use of
$.fn.registerMessagefunction. This function is not a built-in jQuery function, but rather a custom function that you have defined. Therefore, it is possible that the issue might be with the implementation of this function.