When I finished this task, I submitted a username and a password and I received an answer from the form that said " Hurray for client-side validation!". However, I do not see the code that creates this answer in the html file. Where is this code written?
normally the form is send to the back-end (server), where its processed. In this case, that is prevented and JS handles the form (see login.js), there should be a directory/folder icon somewhere which shows you all the files in this exercise
You are right! I found the directory and there are 4 files (2 html, 1 CSS and 1 JS called login.js).
You have been of great help. Now I understand a bit more what happens in this code.
I haven’t really done much, you went through the code and improved your own understanding. Nice job
If you type ‘codecademy’ into the Username field and ‘ilovecoding’ into the Password field you will receive the message, ‘We love coding too!’.
I discovered this after looking at the js file.
thanks so much for this… but also how can one make this else if statement to occur on the browser? have been trying to understand it
one of the fields needs to be false (which is then flipped to true (with not operator (
so leaving one or both fields empty should do the tricky
But remember the field was made to be mandatory… so when I left any empty I was asked fill it in…
my question is “how do i get the “add some client-side validation” message to appear?”
I haven’t done the exercise, and I couldn’t find the exercise url anywhere, do you have it for me?
if you have html5
required attribute, I don’t think you can get the else if
but that is the point? The message says add some client validation for a reason. This message is there to inform you forgot to add validation
Ok… maybe it is because it is an example.
this is the link to the lesson
I think I covered it? the
else if clause is there to inform you that you forgot to add validation to your form.
getting the else if clause to be executed would be a bad thing
ok…so the html code needs to be corrected so the “else if” message can show?
Maybe this lesson doesn’t use the greatest example, but using exceptions/condition to prevent an unwanted outcome (or display a message) is good practice
thank you so much for your contribution