hi i wrote a script that check the input value. It works fine for this code.
javascript
form:
I would like to implement it for multiple row input. Now i am facing problem to do this. Please tell me how I could make it work for multiple row input.
One more thing, for example if i want the value of input1<=99 then how could i check it.
Thanks.
javascript
HTML:
<SCRIPT language="javascript" type="text/javascript">
<!--
function checknumber(x){
var anum=/(^\d+$)|(^\d+\.\d+$)/;
if (anum.test(x)) {
return true;
} else{
return false;
}
}
function check_form(form) {
s = form.input1;
t = form.input2;
u = form.input3;
if (s.value == '' || !checknumber(s.value)) {
alert("Please input a valid Number!");
s.focus();
return false;
} else if (t.value == '' || !checknumber(t.value)) {
alert("Please input a valid Number!");
t.focus();
return false;
} else if (u.value == '' || !checknumber(u.value)) {
alert("Please input a valid Number!");
u.focus();
return false;
} else {
return true;
}
}
//-->
</SCRIPT>
form:
HTML:
<form method="post" action="process.php" onsubmit="return check_form(this)">
<table border="0" width="60%" align="center">
<tr>
<td><STRONG>Enter Values: </STRONG></td>
<td><INPUT name=”input1” type=”text” ></td>
<td><INPUT name=”input2” type=”text” ></td>
<td><INPUT name=”input3” type=”text” ></td>
</tr>
<tr>
<td colspan="4" align="center">
<input type="submit" value="Submit" name="Submit_button">
</td>
</tr>
</table>
</form>
I would like to implement it for multiple row input. Now i am facing problem to do this. Please tell me how I could make it work for multiple row input.
PHP:
<form method="post" action="" onsubmit="return check_form(this)">
<table border="0" width="60%" align="center">
<?php
$num=$_GET['num'];
for($i=0; $i<$num; $i++){
echo "<tr>
<td><STRONG>Enter Values: </STRONG></td>
<td><INPUT name=input1[$i] type=text ></td>
<td><INPUT name=input2[$i] type=text ></td>
<td><INPUT name=input3[$i] type=text ></td>
</tr>";
}
?>
<tr>
<td colspan="4" align="center">
<input type="submit" value="Submit" name="Submit_button">
</td>
</tr>
</table>
</form>
One more thing, for example if i want the value of input1<=99 then how could i check it.
Thanks.