takeiteasy Posted July 3, 2006 Share Posted July 3, 2006 Hi all, can i ask if there's a code for data validation like for example, i have this [code]Amt. Paid: SG$ <input type = 'text' name='amtpaid' size='10' maxlength='10'>[/code]and in my database, the type is Varchar(10).Currently, it can store any kinds of character, but what i wanted is only numbers and decimals to be stored into the database. So is there any code or way that the system will check if it is only numbers and decimals den it can be added to the database, if not a prompt to inform the user that only numbers can be proceed.TIA! Quote Link to comment https://forums.phpfreaks.com/topic/13515-data-validation/ Share on other sites More sharing options...
zq29 Posted July 3, 2006 Share Posted July 3, 2006 You could use ereg() in your processing script, maybe something like:[code]if(ereg("[0-9]*\.[0-9]{2}",$amtpaid)) echo "Everything is OK";[/code]If you want to do this prior to your processing, you'd need to use a client side language, such as JavaScript. Quote Link to comment https://forums.phpfreaks.com/topic/13515-data-validation/#findComment-52461 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.