Jump to content


Invalid user data highlighted

  • Please log in to reply
2 replies to this topic

#1 pxxb

  • Members
  • PipPip
  • Member
  • 10 posts

Posted 02 October 2013 - 02:10 PM

I have a program that lets the user type in the year and if the year is not numeric or isn't 4 digits it will display an error when user presses submit.

I am wondering, how would I make it so the text box gets highlighted if the user types an invalid year? I know it's done through css but that's about all.


#2 requinix

  • Administrators
  • Lazy Administrator
  • 9,242 posts
  • LocationWA

Posted 02 October 2013 - 06:06 PM

How does your thing work? AJAX? Regular form submission? How do you determine there's an error? How do you pass along the error message? Need to know more.

As for the highlighting itself, highlighted how? CSS's background, border, and/or outline properties are probably what you're looking for.
The Reimann Zeta Function Trolley Problem | "Summer is when I, the great ice fairy, can show my true power!"

#3 Barand

  • Moderators
  • Sen . ( ile || sei )
  • 17,736 posts

Posted 02 October 2013 - 09:15 PM

Just use a different CSS style for the fields with an error

<style type="text/css">
input[type='text'].error {
    background-color: #FF0000;
    color: white;
<form method="get">
Year: <input type="text" name="text" value="2013" size="6">
Year: <input class='error' type="text" name="text" value="2o13" size="6">
<input type="submit" name="btn" value="submit"   class="error">

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received


|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users