Need help with forms!

Ok I will be a beginner on making websites and I am wondering how I’d make someone have to fill out a field (in this case it is just a checkbox to be in accordance the terms and conditions) Here is what I get right now

Without thinking about your attachment, there are a few ways.

To begin with, it is advisable to let the user know which areas are mandatory. This is largely done by providing that field a asterix and somewhere close to the form state that an asterix(*) means that is the required field.

To actually ensure they don’t miss a field, you would assign in which form element into a php variable, toned it, and and then check it’s duration.

The reason behind trimming, is than a smart user could simply fill ones field with spots, so technically the variable may very well be equal to…

PHP:


$required 
$_POST'required_field';   //  could  be  equal  to  "          "

So, make it happen instead

PHP:


$required 
$_POST'required_field';
$required  trim($required);


Then use strlen to check the length. In the event zero, the field is empty.

Also, similar can often be done in JavaScript, POST chose PHP while your extension was. php

Okay so would I just paste that into what We have so far and replace the $required by using $termsandconditions
Thanks

If terms and donditions is a required field, your own code will glimpse something like

PHP:


$terms 
$_POST'termsandconditions';
$terms  trim($terms);
if(
strlen($terms)  >   0)
 
       
//  they  entered  something
 

else
 
       
//  they  did  not.
 


Assuming your own form element is actually named.

This entry was posted in Web Design and tagged , , , , , , . Bookmark the permalink.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *