0
I have set error msg for form validation.. but trying to figure out how to remove error msg
Please help me to progress in this tiny appđ https://code.sololearn.com/WK0XU6f0mp1x/?ref=app
10 Answers
0
Nice design :)
You may be aware that in code playground you need to wait for document load ends before accessing DOM as it seems you've tried to wrap initialisation part in an onload event handler... but...
The functions defined outside this main handler, doesn't have access to this function scope, and the reference you've defined at start (const title, author, isbn; outside the init function, in global scope) are still initialized with 'undefined' or 'null', as they are assigned before DOM was ready (and targeted elements accessible).
A better and cleanest way would been to wrap your whole code in the main handler (no polute global scope, and private global-like scope -- kind of anonymous namespace), but now that's quickest to fix as is:
Replace global const init by just var declaration:
var title, author, isbn;
... and delete 'const' from these 3 variables initialisation in the init function (no 'var', no 'let': you want to assign the global vars for being accessibke from outside).
That's all folks !
0
have set error msg for form validation.. but trying to figure out how to remove error msg
0
I told you at end of my first post after explanation of how and why:
now that's quickest to fix as is:
Replace global const init by just var declaration:
var title, author, isbn;
... and delete 'const' from these 3 variables initialisation in the init function (no 'var', no 'let': you want to assign the global vars for being accessible from outside).
0
Thanks for explanations đ I fixed that what you said..
But i am sorry mate my question is different.. I have made function to display error msg if you don't fill input fields and try to add book ..
Please try to run my app again..
0
I don't understand your problem: if you follow completly my advices, your code will work fine, form validation included... (even if your last saved version is not working at all (blank page) if you run it in this intermediate state (you only follow the first part of the 2 things to do -- don't forget the last paragraph ^^)
0
Please try to run app now.. press "ADD BOOK" button without filling any inputs.. it will display error msg ("title mus be filled, author must be filled, isbn must be filled " under respective input fields...
0
Well, that's now working, isn't it?
... Even if time of loading is quite long ;P
But I have found the accountable: remove the font-awesome js script, and you'll got an instant loading :)
0
... and error msg are displayed as they must ^^
0
Yeah thanks.. trying to make a function that removes error msg displayed on screen