I'm new here and my english is not perfect.
I want to validateForm that examined the forms are not empty or if the data are numbers. If not, then the message and I would like to previous data in forms have. If so, then the message and redirect to another page.
Forms are created in the loop: for. I can not find a solution, I tried in javascript, but maybe you know other solutions. Thank you.
<form name="ilosc" method="post" action="test5.php" onsubmit="return validateForm();" action="#">
<?php
for($i = 1; $i <= $num_rows; $i++)
{
echo '<tr><td><input type="text" size=7 name="xxx['.$i.'][ilosc]"/></td></tr>';
}
echo '<p><input type="button" value="...Add..." onclick="validateForm()"/></p></form>';
?>
<script type="text/javascript">
function validateForm() {
var x = document.forms["ilosc"]["xxx['.$i.'][ilosc]"].value;
if (x==null || x=="") {
alert("Stop");
}
else
document.form.submit();
}
</script>`