1
116
I have this script to maintain a 4 character entry done with a hidden field,
but i have an issue with people putting leading zeros. How can I have an
alert when a leading zero is entered and exit the script?
<script>
function sortdashno()
{
with (document.forms[0])
{
{
if (DASHNO.value.substr(0,1) = 0)
alert("Please remove leading ZERO");
else if (DASHNO.value < 10)
DASHNOSORT.value = "000" +DASHNO.value;
else if (DASHNO.value > 10 && DASHNO.value < 100)
DASHNOSORT.value = "00" +DASHNO.value;
else if (DASHNO.value > 100 && DASHNO.value < 999)
DASHNOSORT.value = "0" +DASHNO.value;
}
}
}
</script>
Thanks
David
but i have an issue with people putting leading zeros. How can I have an
alert when a leading zero is entered and exit the script?
<script>
function sortdashno()
{
with (document.forms[0])
{
{
if (DASHNO.value.substr(0,1) = 0)
alert("Please remove leading ZERO");
else if (DASHNO.value < 10)
DASHNOSORT.value = "000" +DASHNO.value;
else if (DASHNO.value > 10 && DASHNO.value < 100)
DASHNOSORT.value = "00" +DASHNO.value;
else if (DASHNO.value > 100 && DASHNO.value < 999)
DASHNOSORT.value = "0" +DASHNO.value;
}
}
}
</script>
Thanks
David