JavaScript Program to Change Color of Textbox if Empty String Submitted

Write a JavaScript program to change color of textbox if empty string submitted.

Source Code
<title>Change Color of Textbox if Empty String Submitted</title>
function fun()
	txt = document.getElementById('t1').value
	if(txt.length == 0)
	    document.getElementById('t1').style.borderColor = "red"
    <input type="text" id="t1">
    <input type="button" value="Submit" onclick="fun()">

"Coding Hub - Learn to code" app now available on Google Play Store