Title: Highlighting required fields
Last modified: August 18, 2016

---

# Highlighting required fields

 *  [marzar00](https://wordpress.org/support/users/marzar00/)
 * (@marzar00)
 * [22 years, 1 month ago](https://wordpress.org/support/topic/highlighting-required-fields/)
 * Does anyone know how to do this? What I mean is that if someone fills out a form
   and miss a required field it highlights when they click submit.
    Any help is 
   much apperciated! Regards Marzar

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [Ozh](https://wordpress.org/support/users/ozh/)
 * (@ozh)
 * [22 years, 1 month ago](https://wordpress.org/support/topic/highlighting-required-fields/#post-48495)
 * I think a quick googlage with keywords such as “javascript validate form” will
   lead you to plenty of javascript ready for use.
 *  [MaxT](https://wordpress.org/support/users/maxt/)
 * (@maxt)
 * [22 years, 1 month ago](https://wordpress.org/support/topic/highlighting-required-fields/#post-48507)
 * That can be also done with PHP if you hate JS (as well as I do even after I *
   have* to use it some places). [VDeamon](http://www.x-code.com/vdaemon_web_form_validation.php)
   is very powerfull PHP library to check any form you want, be it mail field, date
   field with special formatting, url etc. And you you free to sit down and make
   sure your JS expressions will work as they are intended.
    [http://www.MaxT.dk](http://www.MaxT.dk)
 *  [Ozh](https://wordpress.org/support/users/ozh/)
 * (@ozh)
 * [22 years, 1 month ago](https://wordpress.org/support/topic/highlighting-required-fields/#post-48515)
 * I’m not too fond of javascript, but form a user’s POV it’s often better to process
   a few tests client-side rather than server-side. Like, I really hate to submit
   a form, wait 5 seconds on a slow server, then get a message telling me to fill
   this or that (and occasionnaly lose all other fields data in a failed page refresh
   🙂
     Anyway, here is a way to “highlight” a missing mandatory input. I finally
   did it because it has turned as a challenge for me when I couldnt tell why my
   first try wasnt working 🙂 ` <script language="JavaScript"> <!-- function isValid(
   thing) { email=thing.my_field.value; alert (email); if (email=="") { // the form
   is not ok // you could also add : alert ('this is a mandatory value'); thing.
   getElementsByTagName("label")[0].style.color = "red"; alert ('oh'); return false;}
   else { // the form is ok thing.submit(); return true; } } //--> </script> <form
   name="my_form" id="my_form" method="post" action="yourpage.php"> <label id="my_label"
   name="my_label" for="my_field">Mandatory value:</label> <input type="text" id
   ="my_field" /> <input type="button" onClick="return isValid(this.form)" value
   ="Ok" /> </form>
 *  Thread Starter [marzar00](https://wordpress.org/support/users/marzar00/)
 * (@marzar00)
 * [22 years, 1 month ago](https://wordpress.org/support/topic/highlighting-required-fields/#post-48646)
 * Where’s the javascript bit??? Otherwise it looks like it will work!
    Regards 
   Marzar

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Highlighting required fields’ is closed to new replies.

 * In: [Everything else WordPress](https://wordpress.org/support/forum/miscellaneous/)
 * 4 replies
 * 3 participants
 * Last reply from: [marzar00](https://wordpress.org/support/users/marzar00/)
 * Last activity: [22 years, 1 month ago](https://wordpress.org/support/topic/highlighting-required-fields/#post-48646)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
