|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Form problem
greetings
I am working with forms, The required fields will have same color as other fields but if the user did not fill it i want to change the color to RED color How can I do that with php and css ? user name password now check if we have empty fields using if(empty ($username) { What should code here to change the color to red } username Password ***** as you see the user forgot to fill his username but not the password so only username color will changed to red also my form is kinda very long contain around 13 field till now is there anyway to get all $_REQUEST['field']; at once? without repeating the $username = $REQUEST['field']; ? and is there anyway to check if field is empty with one code ? without repeating if(empty ($fieldname)) { } Sorry for broken english and thank you in adnvanced |
|
#2
|
|||
|
|||
|
you could do it with css....
PHP Code:
__________________
-- Jason |
|
#3
|
|||
|
|||
|
Why not use Javascript and CSS, and do the testing on the client-side? Otherwise you'll have to send all the information from the form to the server, and assuming not all the required fields are entered you'll need to reload the form and all the values that were entered back into the text boxes.
__________________
Tryst |
|
#4
|
|||
|
|||
|
well,..you can use JS and css,...but what if the client is setup to reject javascript?
![]() |
|
#5
|
||||
|
||||
|
Create an array whose keys correspond to the values you'll be reading in from the form. For example:
PHP Code:
When you process your form results, do something like the following: PHP Code:
Then when you're displaying your form, you can print the fields out as follows: <input type="text" name="username" value="<?php echo $fields["username"][0]; ?>" class="<?php echo $fields["username"][1];?>"> This'll allow you to use the same code to print the original form and to reprint the form with posted values intact if there are errors. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Form problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|