Ok a person clicks on the check box the text field populates with a number 1
I want it to clear if they uncheck the text box now but can't
Here is the code - see function Quantity1()
<script language="javascript">
function OnlyNumbers1() {
document.theFood.qty1.value=filterNum(document.theFood.qty1.value)
function filterNum(str) {
re = /[^0-9\.]+/g;
// remove special characters like "$" and "," etc...
return str.replace(re, "");
}}
function Quantity1() {
if (document.theFood.qty1.checked) {
document.theFood.qty1.value=filterNum(document.theFood.qty1.value)
function filterNum(str) {
re = /[^A-Z\.]+/g;
// remove special characters like "$" and "," etc...
return str.replace(re, "");
} }
if (!document.theFood.qty1.checked) {
document.theFood.qty1.value = 1;
} }
</script>
<tr><td>Regular Box - $20.00</td><td> <input name="RegularBox" id="RegularBox" type="checkbox" value="RegularBox" onclick="Quantity1();" /> - QTY - <input name="qty1" id="qty1" type="text" maxlength="2" size="2" onkeyup="OnlyNumbers1();" /></td></tr>