I want to check a certain section of my string if it contains a substring.
This is my code so far:
var sHexValue = document.getElementById("ColourInput").value;
fnDebugMessage(sHexValue);
if (sHexValue.includes("#", 0)) {
fnDebugMessage("TRUE");
}
So currently it checks the ColourInput if it contains # from the position 0 in the string, however I want to restrict it so it checks only the first character of ColourInput
How do I do this? Any help is appreciated
sHexValueis a#? You can do:sHexValue[0] === "#"if that's the casesHexValue[0] === '#'?