I have the code below as an input for the date, it works fine on all browsers except Firefox. It probably has something to do with event.returnValue=false
being ignored by the browser, how do I fix this?
<html>
<script language="JavaScript">
function Data(evento, objeto){
var keypress=(window.event)?event.keyCode:evento.which;
campo = eval (objeto);
if (campo.value == '00/00/0000')
{
campo.value=""
}
caracteres = '0123456789';
separacao1 = '/';
conjunto1 = 2;
conjunto2 = 5;
if ((caracteres.search(String.fromCharCode(keypress))!=-1) && campo.value.length < (10))
{
if (campo.value.length == conjunto1 )
campo.value = campo.value + separacao1;
else if (campo.value.length == conjunto2)
campo.value = campo.value + separacao1;
}
else
event.returnValue = false;
}
</script>
</head>
<body>
<form method=post action="">
Data: <input type="text" name="txtdata" pattern="[0-9]" maxlength="10" size="10" onKeyPress="Data(event, this)">
</form>
</body>