What will be the output of the following JavaScript code? [code] function validate() { var msg; if(document.myForm.userPass.value.l

Hương Trang

New member
What will be the output of the following JavaScript code?
Code:
function validate() 
{  
    var msg;  
    if(document.myForm.userPass.value.length>5)
    {  
        msg="good";  
    }  
    else
    {  
         msg="poor";  
    }  
    document.getElementById('mylocation').innerText=msg;  
}  
<form name="myForm">  
<input type="password" value="rhuld"  onkeyup="validate()">  
Strength:<span id="mylocation">no strength</span>  
</form>
A. Strength: good
B. Strength: poor
C. Strength: no strength
D. Undefined
 
Answer: b
Explanation: The innerText property can be used to write the dynamic text on the html document. It is used mostly in the web pages to generate dynamic content such as writing the validation message, password strength etc.
 

Tìm kiếm

Back
Top