javascript string contains
var string = "foo",
substring = "oo";
console.log(string.includes(substring));
javascript string contains
var string = "foo",
substring = "oo";
console.log(string.includes(substring));
string.contains javascript
var str = "We got a poop cleanup on isle 4.";
if(str.indexOf("poop") !== -1){
alert("Not again");
}
javascript validate that input contains certain string
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<input type="text" id='input'>
<button type="button" onclick='btn()'>Alert</button>
<script>
function btn(){
var input=document.getElementById('input').value;
var subs=[
'name','what','child','all','candy'
];
for (let i = 0; i <subs.length; i++) {
if(input.includes(subs[i])){
alert("includes " + subs[i]);
}
else{
console.log('dosnt include '+ subs[i]);
}
}
}
</script>
</body>
</html>
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us