I am trying to search a string to see if it contains a period "." I loaded the value of an input field into a variable then ran a javascript string search() method on that variable.
var _email = document.getElementById(Input).value;
var contains_dot = _email.search(".");
The contains_dot variable should return -1 if a period is not found in the string OR a number representing the position of the match.
Sadly... the variable 'contains_dot' returns nothing but 0 every time. Am i doing something wrong? ..is there a better way?
Please note:
contains_dot = _email.indexOf(".");
Does NOT work for this question as it returns 0 no matter what the input.