Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





How To Update Form Input Field Background Colour On Validation Error


I have been searching for form validation scripts for ages and all th ones that I like are far too complicated and inflexible so I decided to stick with my own which is easier to understand.

The only thing I don't like which i have seen on better form validation scripts is that and fields with errors are highlighted.  i can only presume that they have used php to set the background color of the input field or textarea.

How would I add some code to change the background colour of form elements if an error is found? Here is my code which validates the form but doesn't change form elements colours. Code:




View Complete Forum Thread with Replies

Related Forum Messages:
Validation Of Field Input In Form
Can someone/ANYONE please PRETTY PLEASE help me with my validation of form input?

I am trying to fix my form so that if a person doesn't fill out a field, it will NOT post to Mysql, but instead give an error message and allow the person to go back and input the information.

Here is what I have so far but I'm getting an error when the form is not filled out and I click submit: Code:

View Replies !
Background Colour Not Showing
I need to use a coloured background for a page which contains tables. Using
Frontpage 2k I can create the background colour OK and it views correctly;
but when viewed using apache, there is no background colour, it is just
white.

View Replies !
Change Background Colour
I want to display my query results using alternate background colours like the screen shot attached. Code:

View Replies !
Calender Change The Background Colour
im have made a calender that i want to tie into a sql database , and depending on the value in the database will change the background colour of that day in the calender, the problem im having is with the following:

$colour = "#FF0000"; // this is just to test whether the background colour changes
$cal_event_opentd = "<td align=center bgcolor=#<?php echo $colour;?><b>"; 

but for some reason the backgroud doesnt change,can anyone tell me where im going wrong.

View Replies !
Background Alternating Colour Code
Im having problem making my background alternate between colors.  Following is my code, the result alternates 2 colors ok, but prints each entry from my database 30 times. Code:

View Replies !
Use Session Variables To Pass The Background Colour Of A Page
I am trying to use session variables to pass the background colour of a page loaded into a frame using session variables. I declare tyhe colour in the main page which loads first, this is the content in the main page and echos OK.

$_SESSION['content_color'] = "#E9E9E9";
echo $_SESSION['content_color'];

However if I echo the session variable in my loaded page in another frame I don't get anything at all.

View Replies !
Form Field Validation
When validating user input I check it's not empty and then run 'mysql_real_escape_string($s)', I was then going to make sure that it is only alphanumeric, but I wanted to allow certain other characters as well. Realising this must be done before the mysql escape check, what characters should be blocked because they are dangerous, I can only really think of quotes and $. The real escape check should handle the quotes issue, so is the $ an issue or not? 

View Replies !
Form Text Field Validation
I've got a form and I'm now trying to validate the text fields in it. The field I want to validate is for someones name, so there should only contain letters. Below is the function I've written to handle this. Code:

View Replies !
Form Field *required* Validation
I have php form I'm trying to edit. Some of the fields on this form is required, and some aren't. I want to adjust it so none of the field is required.  But I am not able to find the place to set this value.

Following are 2 piece of the code for 2 fields, 1 is required and 2nd is optional. Please help me determin where I might be able to adjust the validation. Code:

View Replies !
Form Validation :: Check Each Field
I have many forms on my site and so far just check to see if my vars have a value and if not just show a messages saying please fill out such and such a field. What i want to do is, check that each form field has a value and for the ones that dont, send the appropriate error message or number to another script that displays the error messages.

This way I have one error page used to display various errors from all forms of my site. So i need a way to send the error messages to the error page. Like an array then i can just iterate the error array to display each message. Why the extra page? Cause i'm using a template that wont be easy to put directly into form processing scripts. It could be done but i would prefer a cleaner method.

View Replies !
How To Limit Form Field Input?
I'm wondering if there is an easy way to limit a user's input in a text field to 1000 characters?

View Replies !
PHP Form Field Update...
I am sure this has been answered here somewhere, but I have searched for a good 2-3 hours and can't seem to locate a solution. Additionally, I really don't want anyone to solve this mystery for me (at least not all the way!) - But I was hoping someone could point me in the right direction here.

I am trying to figure out how to update form field information before the end user hits the submit button - for example, if they select that they are from California from the "state" drop down list, only counties from California would show up in the "county" drop down list. BTW, this is only a hypothetical example - I am only using this code to build a photo manager for my website!

Anyone able to:

1) tell me what this process is called - it's hard to search for answers when you don't know what you're looking for.

2) point me in the right direction of a solution.

View Replies !
<input Type=file> How To Update Form Data In Mysql
i have been struggling with a problem with file uploads and mysql for a while on and off and have recently dug out my php bible to learn some more i figured out, after a lot of reading and hours of trial and error, how to use a html form to upload text and file paths into a mysql database.

i`m a relative newbie, so i`ve not had time yet to try everything out. my problem is when i use <input type=file> i save the path to an image etc that i have uploaded in a mysql db, but if i want to change any of the text data within my form i cannot keep the image path in the db, but i have to browse for the image again or it will be a broken link? Code:

View Replies !
Clearing The Input Text Field After Submiting The Form To A New Page
I have a page with a form with an input text field ... and when a user types his/hers ID ... and submits the form - his/hers page opens in a NEW window .... but the value (ID) that was written in the original window remains.

I want to make sure that the form input field on the original page becomes "invisible" - by refreshing/reloading the original page or just by clearing the input form after submission.

For now I have put in a meta refresh tag in the head of the html file ... but that is not the solution ... becouse I only need a one time refresh/reload of the page ... and this is to happen right after the input text value is being submitted.

View Replies !
Checkbox Form Field Making Sticky And Remembering Input
I'm trying to get a form with checkboxes to be sticky and to remember what the person checked.

I am using sessions and when I echo the results of the checkboxes the correct result appears. Thus far, all the code I've found makes all the boxes checked.  After the person clicks submit, I only want the boxes checked that the person checked. Code:

View Replies !
Cell Colour Based On Field Data
I have a mysql database and i am using php to display some field data in a table cell on a page. The field data is either 'failed' or 'passed', how can i make the cell colour change depending on the field data result?

View Replies !
Form Validation And Error Message
I've got a drop down menu that I would like to consider mandatory. If it's not selected, I'd like to display an error on the page close to the drop-down, if it is selected, the form should post to another page.

I've tinkered with a little javascript which I couldn't figure out. I've used a switch to display different dropdowns and that works fine, I've just included one as an example. Here's what the form looks like: Code:

View Replies !
Email Form Error Checking And Validation
I have an email form that i use and I cannot seem to get it to ensure that all the field i need fill to be filled.

Here is the php code...

<?php
if(isset($Submit))
{
if ($_POST['category'] == 'Select a category') {
header("Location: error.htm");
}
if($name!= "" && $email!= "" && $category!= "")
{
$message = "Email from the Website:<br><br>
Name: $name<br>
Email: $email<br>
Location: $where<br>
Comment/Question: $needs<br>
Phone Number: $number";

$headers = "MIME-Version: 1.0
";
$headers .= "Content-Type: text/html; charset=iso-8859-1
";
$headers .= "From: <$email>
";
$headers .= "Reply-To: <$email>
"; //comment this is the new code
if (strstr($email, '@') == '@aairp.com') {exit('nice try');}
mail("$category", "Email from the Website", $message, $headers);


header("Location: thanks.htm");
}
else
{


View Replies !
Form Input Error Checking
Have a form field being inserted, needs to only allow an integer value through. Which function do I want to use to check the passed var to see if there are any non-integer values present? PHP Code:

View Replies !
Form Validation :: Reload The Page With Red Error Message
I wrote the following form so that if a user leaves a field blank the page will not process and instead be re-loaded with a red error message asking the user to enter the missing information: Code:

View Replies !
Session Question - Value Of The Input Text Field (<input>) Didn't Change
I'm trying to learn about PHP's session. But, I still get problem. Here's a script (form.php) that I made. I wondering why the value of the input text field (<input>) didn't change when I enter C++ and press the Send button. Code:

View Replies !
Update Form Throws "Undefined Index" Error For Unchecked Radio Button Fields On Form
I have display error ON and error reporting to E_ALL.

I have a form that opens fine. When you submit it, all the fields that have
nothing in them, for example an un-selected radio button, throw the error
similar to that below.

Notice: Undefined index: fld_ONECHOICE in /usr/..../updateFORMFACT.php on
line 29

These fields are not required for the form to be completed.

Do I HAVE to default all fields to yes/no or some entry? Surely not.

Is this just something that shows with error reporting set to E_ALL and I
shouldn't worry about it?

View Replies !
How The Pre-fill The <input Type="file" /> Field Of A Form.
On a user workstation there is a file linked to many other files. The user
upload this file to my server. I can build a list of these files. But I
don't know the path to these files on the workstation. PHP does not give
this information. I am looking for a simple solution from the user point of
view for him to send me all these files.

Because I don't know the path to the file, I can ask the user to type the
path in a dialog box.

I don't have, from the server, a possibility to upload the files on the
workstation. And I don't know how the pre-fill the <input type="file" />
field of a form.

View Replies !
Update Query - Way To Update All Records That Meet Only A Part Of Field
I know that if you use the following code..

UPDATE
table
SET
field = ""
WHERE
field1 = ""

than it will change `field` in all records that meet the criteria of field1. What I need to know is there a way to update all records that meet only a part of field1

ie...

UPDATE
table
SET
field = "yummy"
WHERE
field1 = "apples|oranges"

if field one contains apples|oranges|grapes

it would still pick up that record.

View Replies !
How To Update A Table's Field With Another Tables Field?
I need to take the state field from dt_profile table and update the dt_matchfinder with this state making sure the member_id field matches.

the problem is the dt_matchfinder table has null set for many of the state field but in the dt_profile each member ID has a specific state and I need the same to be true in the dt_matchfinder table.

View Replies !
Input Validation
The idea is to have a way to seperate business rules and validation rules from programming logic and have a shared set of rules for both php and javascript. Here is a code snipet to show you how much time/coding this type of framework could save you. I'm still in the early stages of development and have some issues to work through but this should give you the idea.

    include_once "xml_rule_validator.php";
   
    $xrv = new XMLRuleValidator();
    $xrv->load_from_file("xml_validation_rules.xml");
   
    $valid = $xrv->validate_php();
   
    if( !$valid )
    {
       $xrv->display_error_summary();
    }

And that's it... it would validate all get/session/post variables as specified in the xml document. So if you want to add or remove a check from a field... you make a simple change to an xml document rather than going in and hunting through lines of code. In my case I've got hundreds and hundreds of lines of code per page down to something like that.

So what are your guys thoughts? Do you have different alternatives that you think are better? Any improvements upon my idea?

View Replies !
Input URL Validation
i got a script to validate URL as input . i dont know how do use it.

(https?|ftp)://[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|] .......

View Replies !
Form Validation :: Combine Validation For Different / Multiple Fields
Now I have the error messages going where i want them to but I cant figure out how to combine validation for different fields. The form due to how I now have it set up as error_msg, error_msg1 and error_msg2 will only reject the form if one field is not filled in. I tried to use the pipe to combine them but had no luck. Will i have to set a different complete validation for each field. Or can i use an array (error_msg = 'error messager here' error_msg1 = 'error message one here') somthing like that. Can you use multiple words in an array? Everything i see on line and in my books show one word one=two sort of This is the code I now have ...

View Replies !
Date Input Validation
I am having a problem with validation.I created a form which requires the user to enter date and the date field in the database accepts only these formats year-month-day, year.month.day or year/month/day.Below are the codes i used,the problem is if the user enters the date in either of these format day-month-year, day.month.year or day/month/year the error message is not displayed and the values are sent as null values to the database.

if(!eregi("^[0-9]+[.-/]+[0-9]+[.-/]+[0-9]+$",$datesent)){the date format is not one of the recomended which are:- year.month.day/year.month.day/year-month-day</p>"; exit;}

View Replies !
Input Validation Woes.
I'm having newbietroubles with validating username and password properly as my "If/else" doesn't behave as I expect it to. Code:

View Replies !
Date Validation - Validate The Input
I'm writing a form processing script where I use drop-down boxes for choosing a date (and time). Can anyone tell me how I can validate the input I get to check it's a real date.
My point is that because the listbox lists 1 - 31 for the day, someone could enter Feb 31 as the input, which isn't a real day.

View Replies !
Tinymce Validation - Validate The Input
Iv create a form that uses tinymce to post contents to my database.

'<h1 align="center"><font color="#0033ff">bla..bla..bla</font></h1><p>bla..bla</p><p align="center"><font color="#993300"><u><strong>bla..bla..blo</strong></u></font></p><p>ghkfgf;&nbsp;</p>'

How can i validate this input Code:

View Replies !
Input Validation And Multiple Forms
I am using a content management system written in php. the system allows me to use html blocks.

in one block I have a zip code store search with javascript input validation plus php server side validation if anything makes it past the client side js.

in anotehr block I have another submission form for a sign up with client side javascript validation and php server side validation if anything makes it past the client side.

the javascript validations seem to conflict with each other. By that i mean if i click submit on the one form, the other forms client side validation kicks in.

is there a way to separate the forms in terms of submitting and validation on the client side javascript ? i fire off client side validations with the 'onSubmit()' function by the way.

ALSO, on the zip code entry form I have javascript to prevent them from entering anything but numbers which also conflicts with the other user submissin form. Code:

View Replies !
User Input Validation & Filled Value Should Stay
I am intending to make a form on a page, on pushing submit the forms gets posted  onto itself so that it checks for empty fields and prompts user to get all fields filled, BUT the filled value should stay, I did this easily on ASP, but could not figure out in PHP. Code:

View Replies !
Is There A Benefit To Client Side Input Validation
I already know that there is the benefit (obviously) of reduced server traffic. But I run low-traffic sites, and I'm just wondering if I'm missing something. Why run validation on both ends, as some people suggest, if you're already using server-side validation (besides traffic)?


View Replies !
User Input Validation For A-Z, A-z, 0-9, Punctuation & Spaces
I have an input field called comments and I would like to only allow letters A-Z, a-z, numbers 0-9, punctuation and spaces. Any other input should not allow an insert into a backend DB. This is what I have so far and it's allowing anything. where I am going wrong. PHP Code:

<?
include("config.php");

if (!eregi("^[A-Za-z0-9_ ]+$", $comments))
{
echo "The message must be in the English language for you to send.  Rectify and try again. ";
}
else
{
$connection = mysql_connect("$server","$contactform_dbuser", "$contactform_dbpass");
$db = mysql_select_db("$contactform_database", $connection);
$query = "select * from $inputinformation";
...............

View Replies !
Field Validation
Flushed with that success, I thought I'd tackle the problem of heavy-handedness on the submit button. Over some 10 days I struggled, without success, with all manner of script solutions and finally ripped all trace of that out. Next attempt I thought of would be to use the header route with Location, taking clients to a new page with an acknowledgement for them but without the form itself. No can do, of course, because I ran into the infamous header redirection problem. At the moment, it seems I have no alternative but to rely on mysql to sort out duplicates. Has anyone come across a solid solution to this.

View Replies !
Decimal Field Validation
What is the best way to validate that the decimal field is filled with the properly data in a form? I have a field that ask the user to enter a price quote. I do not want letters or symbols allowed.

View Replies !
Drop Down Field Validation
i am working on a page where office staff enters info on scheduling a doctor for on-call duty. the page has info like  date, shift, Doctors name(Provider) and Location fields and a Add button.

staff selects the date from the calendar, selects a shift from the drop-down, selects a Provider and Location from the drop-down boxes.

When page loads, shift drop-down box defaults to the first value(Shift 1) and Provider and Location fields are defaulted to blank. These fields are to be made mandatory. i am trying what i did on othre screens and it doesnt seem to work here. if i hit the Add button without choosing values for these two fields(just leaving them blank) all validations are skipped. Code:

View Replies !
Field Validation.on A Different Basis.
I have a registration form that my agnets enter leads into... pretty simple, about 50 fields that get stored in MySQl dbase...

Is there a javascript that will alert my agents when they enter a duplicate name that is already in the database?

Im not sure if that is a jscript, or some sort of query line that would be attached to that specific form field to verify names...

View Replies !
File Field Validation $_FILES??
I have the following code that validates my form fields. I have a file field called file that I cant figure out how to validate. Code:

View Replies !
Input Field
Is the below correct in setting a third value (id). PHP Code:

echo '<option value="'.$row['location_ID'].'"&id="'.$row['location_name'].'">'.$row['location_name'].'</option>'
echo ''

View Replies !
Update Query - Update All Tables Field Value To "0"
i wanted to update all my tables field value to "0", but the problem is i got 20 fields

the usual way "update table1 set field1=0,field2=0,field3=0....field20=0 where id='my_id'";

is there a way to update all fields without specifying the fields to update?

View Replies !
Required Field Date Validation In Javascript
I have the following code with javascript where in i am checking whether entered date is valid or not?

I am putting the same for not required field in the form it is not checking the not required column in the form Code:

View Replies !
Spaces In Input Field
I'll give an example of the problem. Someone comes and fills a text field with thier details, like thier address, but they make a mistake and press the space button twice or more between their words. When it echos the words out you cant tell the mistake because the html makes it look 'ok'. But if the input is sent to the database it has spaces between the words.

Is there a way to make sure that only one space is kept between the words before it goes in the databse? I dont want it to say error and make the people fill the form again, i want the script to fix the error.

View Replies !
Disabling Field Input
I'm trying to use PHP to conditionally disable a field within a form.  It's not working out for me, and I don't know why. I have a field called "customizable" which is a Y or N radio box (defaulting to N).

The next field is "character_limit".  If "customizable" is set to N, I want this field grayed out (disabled?)  But if someone checks the "Y" box for "customizable", I want this field to be activated.  Below is the code I tried, showing both fields.  (Note that both fields are contained within the same form): Code:

View Replies !
Compare Field Input
I have made a small script which allow users to demand for additional email account or alias. All existing and new mail addresses and aliases are written to a file. What I want is to automatically check if choose address or alias allready exists in the file. I know I need a loop to compare input field with the file contents but I don't know how to do it.

View Replies !
Save Select Field Input
I am trying to use PHP to save entry on a user input in a form, so that if the user fails the form validation he/she does not have to fill in the information they alread typed in the form the first time. I realize that I can use $_POST['key'] for input fields but I am have trouble with saving select drop down menu input. I figured I would just create a blank option tag and place $_POST['key'] in between the brackets. It works but I know there is a better more robust way to solve this issue. code below...

View Replies !
Stripslashes With Input Field Problem
i am having trouble displaying data in an input form field while using stripslashes()

the data was added to the database using addslashes and is currently in the databse like this: "this is in quotes"

when i try to display that data in an input field by doing this nothing appears:

$strippedtitle = stripslashes($row['title']);
echo "<input name="thetext" type="text" value="$strippedtitle">";

View Replies !
Edit Text In Input Field
I wanted to know how you can insert text to the left and to the right of a marked part of the word. example:

Input field says: ... trees are green ...
By marking this text and using a button I'd like to have
.... <b>trees are green</b> ...

View Replies !
Data Conversion On Field Input
I've got a database that stores routes with a field called distancemiles. Now some visitors prefer to see distances in kilometres, so I have another fields called distancekilometres. At the moment they enter both values manually, which means that errors are possible. To save the person from doing a manual calculation, can I do something to automatically put distancemiles X 1.6 into distancekilometres or distancekilometres / 0.62 into distancemiles.

View Replies !
Can I Set The Value Of A Text Input Field Using A Variable?
Is it possible to do something like this?:

<input type="text" maxlength="10" length="15"  value= some_string_returning_function($value)  />

I am trying to send a form back to the user for him/her to correct a field,
but i want the other fields (already validated) to still have what he had previously entered in them.

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved