I am trying to search a string to see if it contains a period "."
var _email = document.getElementById(Input).value;
var contains_dot = _email.search(".");
The reason why
0 every time is because String.prototype.search takes a regular expression as its input.
. means match any character in regex. In other words, if your input has at least one character of anything, it will return 0.
If you simply change it to
_email.search(/\./);, it will work exactly as you intended.
Browser support: All known browsers
If you don't care about browser support, you may also use
_email.includes('.'); as mentioned by Cade Brown.
See here for reference. Browser support: Only Chrome 41+ and Firefox 40+ (recent browsers)