This is my javascript sample. How can it be improvised?
function a(id)
{
var n=document.getElementById(id);
var re=/^[0-9]:[0-9] [to] [0-9]:[0-9]*$/;
if(re.test(n.value))
{
n.style.backgroundColor="#52F40C";
}
else
{
window.alert("Invalid Entry");
n.style.backgroundColor="#F40C0C";
n.focus();
n.value="";
}
}
I wanna validate user input which should be for example 10:30 to 12:30. I'm a fresher please suggest me.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…