mercredi 23 janvier 2019

Listen for a change on Style on body

The question is relatively simple, i have this piece of Javascript code

bodyElement.style.backgroundColor = inputBodyColorElement.value;

It is tied to my inputBodyColorElement's value which means whatever color i type in the input field, the body's background will assume that color, my issue here is that when you type something that is NOT a color like "hgsdbhfhsdj" It wont give you an error! It wont change the color of the body's background color either, which in turn is what i want from it of course, but i need something i can listen for, to make an if statement that will let the user know that whatever color code, rgb code, or straight text they put in arent correct.

Aucun commentaire:

Enregistrer un commentaire