September 4, 201015 yr Hello, I have developed a form and if the user does not submit something an error occurs. I was wondering how to change the text color <li id="first_name"> <label for="first_name">First name: </label> <div class="fieldgroup"> <?php echo $form->error("first_name"); echo "<br>"; ?> <input name="first_name" type="text" value="<?php echo $form->value("first_name"); ?>" size="35" maxlength="30"></div></li> Right now this is how my code looks. It produces an error when its necessary. But I want to instead of producing that error, I want the First name text to change colors I might have to a if else statement? But not sure how it looks Thanks
September 5, 201015 yr I have developed a form and if the user does not submit something an error occurs. Data validation for form submission is usually done using JavaScript, which is not server side. To change the color of the text of an element, you can add 'OnClick=changeColour()' to the submit button and then create the function changeColour() which changes the styling associated with 'first_name' by using getElementById.
September 5, 201015 yr Author webdesigner93 showed me a way last night on aim. he was really helpful. He got it to work, by changing the color on submit, but I forgot to check another part to it. When I type something in the form, the error disappears. So when I tried to change the original text color, it disappears when the user correctly inputs the right data. How do I make it so it'll go back, Here's his snippet of code that he helped me out with. <?php if($error_tri === FALSE) { echo "Username: "; } else if($error_tri === TRUE) { echo $form->error("user"); } ?>
September 5, 201015 yr webdesigner93 showed me a way last night on aim. he was really helpful. He got it to work, by changing the color on submit, but I forgot to check another part to it. When I type something in the form, the error disappears. So when I tried to change the original text color, it disappears when the user correctly inputs the right data. How do I make it so it'll go back, Here's his snippet of code that he helped me out with. <?php if($error_tri === FALSE) { echo "Username: "; } else if($error_tri === TRUE) { echo $form->error("user"); } ?> Mmm no the below was my code i think u must have changed it <?php if($error_tri === FALSE) { echo "<span style='color:#000000;'>"; } else if($error_tri === TRUE) { echo "<span style='color:#FF0000;'>"; } ?> Username: <?php echo "</span>"; ?>
September 6, 201015 yr Author Yeah, sorry. I did change it a little. I changed it a little so when the user does not enter something, the error pops up. But when the user does enter something, I want the color to change back to the original color text (black). How do I make it convert back to error_tri === False after the error has been set. Currently, it stays red. Thank you
Create an account or sign in to comment