We created a JavaScript function to validate user name, it is working fine, but if i try to use this function to another input validation at the same jsp page, it is showing only text, i included text color in same function but it is not working in second input validation. is it possible to get?, if yes, how can i get?, i am starting level in java script, pls give your answer if anything, thank you.
for example , this is my js function:
function name_validation()
{
if(true){
var unam=document.getElementById("v2").innerHTML="valid";
v2.style.color="green"; //this line is not exist in second input validation
}
else{
var unam=document.getElementById("v2").innerHTML="invalid";
v2.style.color="red"; //this line is not exist in second input validation
}
}
this is my jsp code:
name:<input type="text" id="name" onchange="name_validation();"><a id="v2"></a>
Father name:<input type="text" id="name" onchange="name_validation();"><a id="v2"></a>