Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Handle exception “JavaScript runtime error: Unable to get property ‘length’ of undefined or null reference” on ko.observable field? without wasting too much if your time.
The question is published on by Tutorial Guruji team.
The question is published on by Tutorial Guruji team.
I’m using Knockoutjs on a registration form. I have runtime error when user click button to show password field
JavaScript runtime error: Unable to get property ‘length’ of undefined or null reference
how to handle runtime exception in KO.js?
self.showHidePasswordField = function () { if (self.password1().length > 0 || typeof self.password1().length !== 'undefined') { console.log('show'); } else { console.log('hide'); } };
Answer
Assuming you are sure you defined the password1
observable, you can try the following:
if (self.password1() != null && typeof self.password1().length !== 'undefined')
We are here to answer your question about Handle exception “JavaScript runtime error: Unable to get property ‘length’ of undefined or null reference” on ko.observable field? - If you find the proper solution, please don't forgot to share this with your team members.