I have a regex type of field (^\d+.\d+.\d+$) in an HTML form. If a user enters any of the following versions below, we need the field to display a warning message. Is this possible?
function fx(inp){
string = inp.value;
regex = /^\d+.\d+.\d+$/;
msg = 'your message';
if (regex.test(string)&&inrange(string)){
alert(msg);
}
}
function inrange(string){
ver = string.split('.').map(v => parseInt(v));
if (['4.9.9', '4.9.11','5.1.0'].includes(string)){return true;}
if (ver[0] == 6){return true;}
if((ver[0] == 4)){
if(ver[1] < 5){return true;}
if((ver[1]==5)&&(ver[2]<=6)){return true;}
}
return false;
}
<input type='text' onfocusout='fx(this)'>
Yes, it is possible.
You just need to: