I am novice in php, html and javascript. My aim is to check and validate the user input. My code is working only for one input field which is not in loop. In a moment, I want to check multiple input fields from loop the reply of the code is "* Wrong Insert: undefined, position: null".
Would you be so kind and tell me what am I doing wrong ?
javscript block
function ValidationSubmit()
{
var DatabaseIndex = document.getElementById("3").getAttribute("name");
var CheckInt = document.getElementById("3");
var CheckIntVal = CheckInt.value;
const a=-10;
if( a < 0 )
{
document.getElementById('demo').innerHTML = "* Wrong insert : " + CheckIntVal + ", position: " + DatabaseIndex ;
return false;
}
else
{
return true;
}
php block for calling validation function ValidationSubmit()
echo '<form method="POST" target="_top" action="SaveForm.php?UID='.$UID.'" onsubmit="return ValidationSubmit()">';
php block for user input
$j = 0;
while($j<=10)
{
$ID = strval($j);
echo "<td><input type='text' id='$ID' name='$ID' value='$value[$j]' ></td>";
$j++;
}