Sunday, April 18, 2021

6. Program to change color of the text box if empty string submitted.

6. Program to change color of the text box if empty string submitted.

 <script>
 function funup(val)
 {  
if(val.length>0)       document.getElementById('t1').style.borderColor="silver";
 } 
function fun1()
 {  
txt=document.getElementById('t1').value  if(txt.length == 0)  document.getElementById('t1').style.borderColor = "red" 
</script> 

<input type="text" id="t1" onkeyup="funup(this.value)">
<input type="button" value="Submit" onclick="fun1()">

No comments: