Click here to Skip to main content
13,899,494 members
Rate this:
 
Please Sign up or sign in to vote.
See more:





function myfunc(){
var a=document.getElementById("one");
var b=document.getElementById("two");

for(var i=0;i<=a.length;i++){
if(b[i].value == a[i].value){
b[i].style.color = "yellow";
}
else if(b[i]!= a[i]){
b[i].style.color="red";
}
}

}



What I have tried:

i want to run this code,i want to make two input boxes and i apply fixed text to one input box,so in second box when user enters text that is equal to first input text
so the color of second input box by index wise will be yellow else red
Posted
Updated 11-Jan-19 8:45am
Comments
Patrice T 11-Jan-19 13:47pm
   
"i want to run this code"
Ok go on.
If you have a question, state it.

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

You can learn about HTML input here: HTML Forms[^]
Then copy your code and test your Javascript at: Create a new fiddle - JSFiddle[^]
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web05 | 2.8.190306.1 | Last Updated 11 Jan 2019
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100