i have something like this
<input name="ip" id="ip">
this ip needs to be added to a list of ips that contains multiple ips in this format
<select id="iplist" name="iplist">
<option value="192.168.1.2">192.168.1.2</option>
<option value="192.168.1.10 - admin">192.168.1.10 - admin</option>
<option value="192.168.2.2 - test">192.168.2.2 - test</option>
<option value="192.168.2.9 - test1">192.168.2.9 - test1</option>
</select>
and many other values in the select list (not only the ones listed), when the button is executed and the ip needs to be added to the select option I need to check if the ip is already in the list or not, if is not to return error,
so i have something like this to get the values
var iplist = $.map($('#iplist option'), function(e) { return e.value; });
and console.log is showing all the values in array
console.log(iplist);
To get the values as string i can use
var str = iplist.join(',');
However I have a very hard time to verify if the ip is already in the select list.
Any help is really appreciated, thank you in advance for your time taken to look into this. I'm thinking of regex to verify if the ip exist in array, but I have problems with that because there are multiple values types, delimited by comma also with space, and also without space