-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwordreplace.js
More file actions
30 lines (27 loc) · 817 Bytes
/
wordreplace.js
File metadata and controls
30 lines (27 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
function replaceWord(){
var a=document.getElementById("i_text").value
if(a==""){
alert("Please fill all the fields");
document.myForm.text.focus();
return false;
}
var b=document.getElementById("i_word").value
if(b==""){
alert("Please fill all the fields");
document.myForm.word.focus();
return false;
}
var c=document.getElementById("i_replace").value
if(c==""){
alert("Please fill all the fields");
document.myForm.replace.focus();
return false;
}
if((a.includes(b)==false)){
alert("The word isn't in the text!!!\n Give the word that belongs to text");
return false;
}
let result = a.replaceAll(b, c);
alert(result);
return true;
}