fareedreg Posted December 23, 2009 Share Posted December 23, 2009 attached form required validation ...If withdrawl amount is greater than current balance...?? what is the best way to do this validation. [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/186136-best-way-of-validation/ Share on other sites More sharing options...
Deoctor Posted December 23, 2009 Share Posted December 23, 2009 if u can provide code i think it would be more easier. Link to comment https://forums.phpfreaks.com/topic/186136-best-way-of-validation/#findComment-983000 Share on other sites More sharing options...
fareedreg Posted December 23, 2009 Author Share Posted December 23, 2009 <?php $val=$_POST["txtmemid"]; include('balance.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style type="text/css"> <!-- .style4 {font-size: 36px} --> </style> <script language="javascript" src="gen_validatorv31.js" type="text/livescript"></script> </head> <body> <div align="center"><img src="images/libimage.jpg" width="998" height="103" /></div> <table width="572" height="61" align="center"> <tr> <td align="center"><p class="style4">MEMBER DEPOSITE</p> <p class="style4"><a href="index.html"><img src="images/mainmenu.gif" /></a><a href="memberdeposite.html"><img src="images/return.gif" /></a> </p></td> </tr> </table> <p> </p> <form name="memdeposite" method="post" action="memdepupdate.php"> <table width="495" border="0" align="center"> <tr> <td>Member Id</td> <td><input name="txtmemid" type="text" id="memid" readonly="readonly" value="<?php echo $val;?>" size="12" maxlength="5" /></td> </tr> <tr> <td width="189" height="45"><label for="id">Member Name</label></td> <td width="296"><input name="txtmemname" readonly="readonly" value="<?php echo $memname;?>" type="text" id="txtmemname" /></td> </tr> <tr> <td height="37"><label for="amt">Withdrawl Amount</label></td> <td><input name="txtdepamt" type="text" id="txtdepamt" size="12" maxlength="9" /></td> </tr> <tr> <td>Deposite Date</td> <td width="296"><input name="txtdepdd" type="text" id="txtdepdd" size="2" maxlength="2" /> <input name="txtdepmm" type="text" id="txtdepmm" size="2" maxlength="2" /> <input name="txtdepyy" type="text" id="txtdepyy" size="6" maxlength="4" /> (dd mm yyyy)</td> </tr> </table> <p> </p> <table width="140" border="0" align="center"> <tr> <td width="74" height="27"><input type="submit" value="Submit" /></td> <td width="48"><input type="reset" /></td> </tr> </table> <p> </p> <table width="206" border="1" align="center"> <tr> <td width="124" bgcolor="#99FFFF"><strong>Current Balance</strong></td> <td width="95"><label><b><?php echo $totalamt;?> INR </b></label> </td> </tr> </table> <p> </p> <p> </p> <script language="JavaScript" type="text/javascript" > var frmvalidator = new Validator("memdeposite"); frmvalidator.addValidation("txtmemid","req","Please enter Member Id"); frmvalidator.addValidation("txtmemid","numeric","Id must be numeric"); frmvalidator.addValidation("txtmemname","req","Please enter Valid Id"); frmvalidator.addValidation("txtdepamt","req","Please Enter Deposite Amount"); frmvalidator.addValidation("txtdepamt","maxlen=11","Max Length for Amount is 11"); frmvalidator.addValidation("txtdepamt","dec","Amount must be in Decimal Form"); frmvalidator.addValidation("txtdepdd","req","Please Enter Date"); frmvalidator.addValidation("txtdepdd","numeric","Date must be numeric"); frmvalidator.addValidation("txtdepmm","req","Please Enter Month"); frmvalidator.addValidation("txtdepmm","numeric","Month must be numeric"); frmvalidator.addValidation("txtdepyy","req","Please Enter Year"); frmvalidator.addValidation("txtdepyy","numeric","Year must be numeric"); </script> </body> have a look then\ if u can provide code i think it would be more easier. Link to comment https://forums.phpfreaks.com/topic/186136-best-way-of-validation/#findComment-983006 Share on other sites More sharing options...
Deoctor Posted December 23, 2009 Share Posted December 23, 2009 <?php $val=$_POST["txtmemid"]; include('balance.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style type="text/css"> <!-- .style4 {font-size: 36px} --> </style> <script language="javascript" src="gen_validatorv31.js" type="text/livescript"></script> </head> <body> <div align="center"><img src="images/libimage.jpg" width="998" height="103" /></div> <table width="572" height="61" align="center"> <tr> <td align="center"><p class="style4">MEMBER DEPOSITE</p> <p class="style4"><a href="index.html"><img src="images/mainmenu.gif" /></a><a href="memberdeposite.html"><img src="images/return.gif" /></a> </p></td> </tr> </table> <p> </p> <form name="memdeposite" method="post" action="memdepupdate.php"> <table width="495" border="0" align="center"> <tr> <td>Member Id</td> <td><input name="txtmemid" type="text" id="memid" readonly="readonly" value="<?php echo $val;?>" size="12" maxlength="5" /></td> </tr> <tr> <td width="189" height="45"><label for="id">Member Name</label></td> <td width="296"><input name="txtmemname" readonly="readonly" value="<?php echo $memname;?>" type="text" id="txtmemname" /></td> </tr> <tr> <td height="37"><label for="amt">Withdrawl Amount</label></td> <td><input name="txtdepamt" type="text" id="txtdepamt" size="12" maxlength="9" /></td> </tr> <tr> <td>Deposite Date</td> <td width="296"><input name="txtdepdd" type="text" id="txtdepdd" size="2" maxlength="2" /> <input name="txtdepmm" type="text" id="txtdepmm" size="2" maxlength="2" /> <input name="txtdepyy" type="text" id="txtdepyy" size="6" maxlength="4" /> (dd mm yyyy)</td> </tr> </table> <p> </p> <table width="140" border="0" align="center"> <tr> <td width="74" height="27"><input type="submit" value="Submit" /></td> <td width="48"><input type="reset" /></td> </tr> </table> <p> </p> <table width="206" border="1" align="center"> <tr> <td width="124" bgcolor="#99FFFF"><strong>Current Balance</strong></td> <td width="95"><label><b><?php echo $totalamt;?> INR </b></label> </td> </tr> </table> <p> </p> <p> </p> <script language="JavaScript" type="text/javascript" > var frmvalidator = new Validator("memdeposite"); frmvalidator.addValidation("txtmemid","req","Please enter Member Id"); frmvalidator.addValidation("txtmemid","numeric","Id must be numeric"); frmvalidator.addValidation("txtmemname","req","Please enter Valid Id"); frmvalidator.addValidation("txtdepamt","req","Please Enter Deposite Amount"); frmvalidator.addValidation("txtdepamt","maxlen=11","Max Length for Amount is 11"); frmvalidator.addValidation("txtdepamt","dec","Amount must be in Decimal Form"); frmvalidator.addValidation("txtdepdd","req","Please Enter Date"); frmvalidator.addValidation("txtdepdd","numeric","Date must be numeric"); frmvalidator.addValidation("txtdepmm","req","Please Enter Month"); frmvalidator.addValidation("txtdepmm","numeric","Month must be numeric"); frmvalidator.addValidation("txtdepyy","req","Please Enter Year"); frmvalidator.addValidation("txtdepyy","numeric","Year must be numeric"); </script> </body> have a look then\ if u can provide code i think it would be more easier. i dont think that any thing u have given willbe useful u just gave the html form.. just give the palce ur are validation for the other things are going on.. i can give u only one solution for this $txtamt=$_post['txtdepamt']; if ($txtamt>$totalamt) { echo "Sorry transaction cannot be possible"; } else { continue with the transaction..blah...blah } use code tags to mention ur code Link to comment https://forums.phpfreaks.com/topic/186136-best-way-of-validation/#findComment-983013 Share on other sites More sharing options...
fareedreg Posted December 23, 2009 Author Share Posted December 23, 2009 You are right i can do it in validation form... but i would like to do it on the same form yaar. <?php $val=$_POST["txtmemid"]; include('balance.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style type="text/css"> <!-- .style4 {font-size: 36px} --> </style> <script language="javascript" src="gen_validatorv31.js" type="text/livescript"></script> </head> <body> <div align="center"><img src="images/libimage.jpg" width="998" height="103" /></div> <table width="572" height="61" align="center"> <tr> <td align="center"><p class="style4">MEMBER DEPOSITE</p> <p class="style4"><a href="index.html"><img src="images/mainmenu.gif" /></a><a href="memberdeposite.html"><img src="images/return.gif" /></a> </p></td> </tr> </table> <p> </p> <form name="memdeposite" method="post" action="memdepupdate.php"> <table width="495" border="0" align="center"> <tr> <td>Member Id</td> <td><input name="txtmemid" type="text" id="memid" readonly="readonly" value="<?php echo $val;?>" size="12" maxlength="5" /></td> </tr> <tr> <td width="189" height="45"><label for="id">Member Name</label></td> <td width="296"><input name="txtmemname" readonly="readonly" value="<?php echo $memname;?>" type="text" id="txtmemname" /></td> </tr> <tr> <td height="37"><label for="amt">Withdrawl Amount</label></td> <td><input name="txtdepamt" type="text" id="txtdepamt" size="12" maxlength="9" /></td> </tr> <tr> <td>Deposite Date</td> <td width="296"><input name="txtdepdd" type="text" id="txtdepdd" size="2" maxlength="2" /> <input name="txtdepmm" type="text" id="txtdepmm" size="2" maxlength="2" /> <input name="txtdepyy" type="text" id="txtdepyy" size="6" maxlength="4" /> (dd mm yyyy)</td> </tr> </table> <p> </p> <table width="140" border="0" align="center"> <tr> <td width="74" height="27"><input type="submit" value="Submit" /></td> <td width="48"><input type="reset" /></td> </tr> </table> <p> </p> <table width="206" border="1" align="center"> <tr> <td width="124" bgcolor="#99FFFF"><strong>Current Balance</strong></td> <td width="95"><label><b><?php echo $totalamt;?> INR </b></label> </td> </tr> </table> <p> </p> <p> </p> <script language="JavaScript" type="text/javascript" > var frmvalidator = new Validator("memdeposite"); frmvalidator.addValidation("txtmemid","req","Please enter Member Id"); frmvalidator.addValidation("txtmemid","numeric","Id must be numeric"); frmvalidator.addValidation("txtmemname","req","Please enter Valid Id"); frmvalidator.addValidation("txtdepamt","req","Please Enter Deposite Amount"); frmvalidator.addValidation("txtdepamt","maxlen=11","Max Length for Amount is 11"); frmvalidator.addValidation("txtdepamt","dec","Amount must be in Decimal Form"); frmvalidator.addValidation("txtdepdd","req","Please Enter Date"); frmvalidator.addValidation("txtdepdd","numeric","Date must be numeric"); frmvalidator.addValidation("txtdepmm","req","Please Enter Month"); frmvalidator.addValidation("txtdepmm","numeric","Month must be numeric"); frmvalidator.addValidation("txtdepyy","req","Please Enter Year"); frmvalidator.addValidation("txtdepyy","numeric","Year must be numeric"); </script> </body> have a look then\ if u can provide code i think it would be more easier. i dont think that any thing u have given willbe useful u just gave the html form.. just give the palce ur are validation for the other things are going on.. i can give u only one solution for this $txtamt=$_post['txtdepamt']; if ($txtamt>$totalamt) { echo "Sorry transaction cannot be possible"; } else { continue with the transaction..blah...blah } use code tags to mention ur code Link to comment https://forums.phpfreaks.com/topic/186136-best-way-of-validation/#findComment-983025 Share on other sites More sharing options...
Deoctor Posted December 23, 2009 Share Posted December 23, 2009 then use the code which i gave u in the same form after the html tags gets completed.. use the php tags Link to comment https://forums.phpfreaks.com/topic/186136-best-way-of-validation/#findComment-983030 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.