![]() |
validating a form, can it have 2 values?
Hey guys, I'm just learning PHP, and I'm trying to validate a form.
The problem I'm having, is with value=Here is a snipit of the form code as an example: Code:
<label>Full NameBut the validation tutorial I'm following is telling me to set the value as Code:
value="<?=$varname;?>How can I have the 'example' of the field and the var so that people don't have to re-enter their information when the form is validated? Please give me an example of the correct code, as I'm still learning :) Thanks! |
Quote:
Rather than using onfocus() and relying of JavaScript - it's annoying anyway to have the value removed each time (suppose I just want to correct the spelling?) - use HTML5 placeholder: PHP Code:
It is also advisable to always use the full php opening tag <?php and echo the value. You'll notice that if you delete the value and click away from the input the placeholder text will show. However, placeholder text should say something useful such as "Name is required" or "Minimum 5 characters" rather than an actual name, as this is mis-leading. BTW I think name is a very poor name for the name. Use a little imagination; even 'fullname' is better. |
Code:
<?php |
Thanks for the advice!
I was unaware of the placeholder attribute :o Can I ask why name is a bad name? I understand it is simple/common but is there a reason that is bad? I'm not very familiar with doctypes. My knowledge of html/css/php is mainly from following tutorials and taking advice from random pages online. People have told me to just use this, so its what I use :D Code:
<!DOCTYPE html> |
| All times are GMT +1. The time now is 07:36 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.