austine_power007 Posted December 7, 2006 Share Posted December 7, 2006 I have a form and I want to be sure that user give only integer value or it will give a error message.I think i can use java script does anyone have that ?? help me :-[ Quote Link to comment Share on other sites More sharing options...
mansuang Posted December 7, 2006 Share Posted December 7, 2006 use regular expressionlink for javascript [url=http://www.phpfreaks.com/javascript_manual/page/regexp.htm]http://www.phpfreaks.com/javascript_manual/page/regexp.htm[/url]link for php [url=http://www.phpfreaks.com/phpmanual/page/ref.regex.html]http://www.phpfreaks.com/phpmanual/page/ref.regex.html[/url] Quote Link to comment Share on other sites More sharing options...
austine_power007 Posted December 7, 2006 Author Share Posted December 7, 2006 [quote author=mansuang link=topic=117681.msg480292#msg480292 date=1165466668]use regular expressionlink for javascript [url=http://www.phpfreaks.com/javascript_manual/page/regexp.htm]http://www.phpfreaks.com/javascript_manual/page/regexp.htm[/url]link for php [url=http://www.phpfreaks.com/phpmanual/page/ref.regex.html]http://www.phpfreaks.com/phpmanual/page/ref.regex.html[/url][/quote]I am new in php and tht don't have much example..........so please send me some easy code so that will be easy for me......sorryy i m NUT Quote Link to comment Share on other sites More sharing options...
bljepp69 Posted December 7, 2006 Share Posted December 7, 2006 For checking the form submission using PHP you could try something like:[code]if (!preg_match('/[^0-9]+/',$FORMVARIABLE)) { //error code goes here}else { //process code here}[/code]I haven't tested this, but it should reject everything that's not an integer. You'll just have to fill in the $FORMVARIABLE with your actual variable and then write the error and process code. Quote Link to comment 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.