dc_jt Posted October 17, 2006 Share Posted October 17, 2006 Hi I have created a form where a user inputs their details.I want to be able to make the form not accept if someone simply just enters a load of ///// or just presses space bar to fill in the form.I thought stripslashes would do this but it doesnt. Any ideas?Here is my form:[code]<div class="formwrapper"> <div class="textlabel">Name</div><div class="formlabel"> <input name="Name" type="text" class="dataform" value="<?=(stripslashes($_POST['Name']))?>" /> </div> <div class="textlabel">Email</div> <div class="formlabel"> <input name="Email" type="text" class="dataform" value="<?=(stripslashes($_POST['Email']))?>"/> </div> <div class="textlabel">Address</div> <div class="formlabel"> <textarea name="Address" rows="2" wrap="virtual" class="dataform"><?=(stripslashes($_POST['Address']))?></textarea> </div> <div class="textlabel">Business Name </div> <div class="formlabel"> <input name="Business_Name" type="text" class="dataform" value="<?=(stripslashes($_POST['Business_Name']))?>"/> </div> <div class="textlabel">Type of Business </div> <div class="formlabel"> <input name="Type_of_Business" type="text" class="dataform" value="<?=(stripslashes($_POST['Type_of_Business']))?>"/> </div> <div class="textlabel">Comments</div> <div class="formlabel"> <textarea name="Comments" rows="2" wrap="virtual" class="dataform"><?=(stripslashes($_POST['Comments']))?></textarea> </div> <div class="textlabel"> </div><div class="formlabel"> <input name="Submit" type="submit" class="databut" value="Submit" /> <input type="hidden" name="mode" value="apply" /> <br class="clear"/> </form>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/24212-disabling-input-or-space-bar-input/ Share on other sites More sharing options...
michaellunsford Posted October 17, 2006 Share Posted October 17, 2006 You can handle spaces with trim(), but regular expression is much more powerful. If you know regex, you can probably figure out how to validate any part of your form. Here's an email validation example:Borrowed from [url=http://www.digitalmidget.com/php_noob/captcha.php]AndyB's CAPTCHA Script[/url][code] if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) { $err.= $email. " is not a valid email address.<br/>"; }[/code][b]PS>[/b] There's a regular expression forum here at PHPfreaks. [url=http://www.phpfreaks.com/forums/index.php/board,43.0.html]http://www.phpfreaks.com/forums/index.php/board,43.0.html[/url] Quote Link to comment https://forums.phpfreaks.com/topic/24212-disabling-input-or-space-bar-input/#findComment-110115 Share on other sites More sharing options...
dc_jt Posted October 17, 2006 Author Share Posted October 17, 2006 Ive done the email validation thats in my class.I just wanted to stop people from just simply pressing the space bar rather than input dataThanks anyway for your help Quote Link to comment https://forums.phpfreaks.com/topic/24212-disabling-input-or-space-bar-input/#findComment-110121 Share on other sites More sharing options...
wildteen88 Posted October 17, 2006 Share Posted October 17, 2006 Use regualar expressions again then. Quote Link to comment https://forums.phpfreaks.com/topic/24212-disabling-input-or-space-bar-input/#findComment-110152 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.