PHP interesse |
|
ik heb de volgende javascriptcodes:
function checkNumeric(text) {
if (text.search(/[^0-9]/) == -1) {
return false;
} else {
return true;
}
}
function checkNumeric(text) { if (text.search(/[^0-9]/) == -1) { return false; } else { return true; } }
en de htmlcode erbij:
<form method="post" action="" name="cartForm{id}" id="cartForm{id}" onsubmit="return checkShopForm('{id}');">
<input name="id" id="id" type="hidden" value="{id}" />
<input type="text" name="number" id="number" value="1" size="2" />
<input type="submit" id="submit_addCart" name="submit_addCart" value="Bestel" />
</form>
<form method="post" action="" name="cartForm{id}" id="cartForm{id}" onsubmit="return checkShopForm('{id}');"> <input name="id" id="id" type="hidden" value="{id}" /> <input type="text" name="number" id="number" value="1" size="2" /> <input type="submit" id="submit_addCart" name="submit_addCart" value="Bestel" />
de {id} word dooe TemplatePower correct ingevuld, in mijn geval is dat 1.
hoe ik mijn formulier controleer is:
function checkShopForm(id) {
var error = 0;
var error_text = "";
var number = document.forms["cartForm"+id].elements["number"];
if (trim(checkNumeric(number.value)) == true)
{
number.className = '';
} else {
number.className = 'error';
error = 1;
error_text += "Invoer is geen getal\n";
}
if (error != 0) {
alert(error_text);
return false;
}
}
function checkShopForm(id) { var error = 0; var error_text = ""; var number = document.forms["cartForm"+id].elements["number"]; if (trim(checkNumeric(number.value)) == true) { number.className = ''; } else { number.className = 'error'; error = 1; error_text += "Invoer is geen getal\n"; } if (error != 0) { alert(error_text); return false; } }
en ik krijg steeds maar de error, wat ik ook invul, getal of niet... Invoer is geen getal....
|