NoPHPPhD Posted October 30, 2006 Share Posted October 30, 2006 I would like to make sure that "Quantity" is > zero when this is submitted.If it is not, I would like to just redisplay the same form.What do I have to do? Probably very simple, just not searching for the right term.... :-\[code]print("<FORM>\n");print("<FORM ACTION=\"AddRecord.php\" METHOD=\"GET\">\n");print("<INPUT TYPE=\"TEXT\" NAME=\"Quantity\">\n");print("<INPUT TYPE=\"HIDDEN\" NAME=\"NBDno\" VALUE = '$pickedNBDno' >\n"); print("<SELECT NAME=\"Measure\">\n"); while($row = mysql_fetch_object($dbResult)) { print("<OPTION VALUE=\"{$row->WeightID}\""); print(">{$row->Description}\n"); } print("</SELECT>\n");print("<INPUT TYPE=\"submit\">\n"); print("</FORM>\n");[/code] Link to comment https://forums.phpfreaks.com/topic/25532-how-to-check-if-field-is-empty-before-submit/ Share on other sites More sharing options...
hackerkts Posted October 30, 2006 Share Posted October 30, 2006 You can try using [b]isset[/b], sorry I doesn't have the time to write out examples. Link to comment https://forums.phpfreaks.com/topic/25532-how-to-check-if-field-is-empty-before-submit/#findComment-116517 Share on other sites More sharing options...
trq Posted October 30, 2006 Share Posted October 30, 2006 You could do something like....[code=php:0]if (isset($_GET['Quantity']) && $_GET['Quantity'] > 0) { // do action.}[/code]Of course this doesn't check the field until after submission (php cant), you would need to use Javascript to achieve that. Link to comment https://forums.phpfreaks.com/topic/25532-how-to-check-if-field-is-empty-before-submit/#findComment-116520 Share on other sites More sharing options...
twofivethreetwo Posted October 30, 2006 Share Posted October 30, 2006 This site http://www.php-mysql-tutorial.com/form-validation-with-php.php has some info on client-side and server-side validation for forms. Might be of some help. Link to comment https://forums.phpfreaks.com/topic/25532-how-to-check-if-field-is-empty-before-submit/#findComment-116553 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.