title: Can we use one java script function to multiple input validation?
body: <p>We created a JavaScript function to <strong>validate user name</strong>, 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.</p>
  
  <p>for example , this is my js function:</p>
  
  <pre><code>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
                }
        }
  </code></pre>
  
  <p>this is my jsp code:</p>
  
  <pre><code>name:&lt;input type="text" id="name" onchange="name_validation();"&gt;&lt;a id="v2"&gt;&lt;/a&gt;
  Father name:&lt;input type="text" id="name" onchange="name_validation();"&gt;&lt;a id="v2"&gt;&lt;/a&gt;
  </code></pre>