Hello I have a form in which a user may enter 0-5 characters. If the user enters less then 5 numbers in this field I need to pad it with 0's to make it 5. Can anyone help me out with this or lead me in the right direction here is what I have tried so far and nothing....
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<script language="JavaScript">
function zeroPad() { // pad string
if (document.forms1.C4.length == 1) {
(0000 + document.forms1.C4.value);
}
}
</script>
<body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action="">
<p>
<input type="text" name="C4" onChange="zeroPad()">
</p>
<p>
<input type="text" name="textfield">
</p>
</form>
</body>
</html>
I am not a javascript programmer so please forgive this question as it is probably very easy to write however I do no have a good command of the language.
Thanks-
K.
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<script language="JavaScript">
function zeroPad() { // pad string
if (document.forms1.C4.length == 1) {
(0000 + document.forms1.C4.value);
}
}
</script>
<body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action="">
<p>
<input type="text" name="C4" onChange="zeroPad()">
</p>
<p>
<input type="text" name="textfield">
</p>
</form>
</body>
</html>
I am not a javascript programmer so please forgive this question as it is probably very easy to write however I do no have a good command of the language.
Thanks-
K.