Jump to content


Photo

Invalid user data highlighted


  • Please log in to reply
2 replies to this topic

#1 pxxb

pxxb

    Member

  • Members
  • PipPip
  • 10 posts

Posted 02 October 2013 - 09:10 AM

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.

thanks.



#2 requinix

requinix

    Playful Member

  • Moderators
  • 5,744 posts
  • LocationWA

Posted 02 October 2013 - 01: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.

#3 Barand

Barand

    Sen . ( ile || sei )

  • Gurus
  • 13,885 posts
  • LocationCheshire, UK

Posted 02 October 2013 - 04:15 PM

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

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

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts
|baaSelect| generate js and php code for dynamic linked dropdowns

 





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com