Title: [Plugin: Custom Field Template] Required fields
Last modified: August 19, 2016

---

# [Plugin: Custom Field Template] Required fields

 *  [carolinem](https://wordpress.org/support/users/carolinem/)
 * (@carolinem)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/plugin-custom-field-template-required-fields/)
 * Love this plugin! I apologize in advance if these questions have already been
   asked… I’ve looked all over but couldn’t find anything.
 * Is it possible to set a field (or multiple fields) as required? Ie. a user must
   fill in a particular field or fields before successfully publishing their post.
 * It would also be great if the fields were automatically labeled for accessibility
   in the backend (ie. <label for=”somefield”>Some Field:</label><input type=”text”
   id=”somefield”>).
 * Again, if this has already been addressed, please point me in the right direction.
   Thanks for a great plugin!

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

 *  [Hiroaki Miyashita](https://wordpress.org/support/users/hiroaki-miyashita/)
 * (@hiroaki-miyashita)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/plugin-custom-field-template-required-fields/#post-1042658)
 * I am looking for some good ways to validate the field values…. This is a temporal
   way to set a field as required by use of JavaScript.
 * Template Instruction
 *     ```
       <script type="text/javascript">
       jQuery('#save-post').click(function() {
       	if(!jQuery('.test').val()) { alert('Empty!'); return false; }
       });
       jQuery('#publish').click(function() {
       	if(!jQuery('.test').val()) { alert('Empty!'); return false; }
       });
       </script>
       ```
   
 * Template Content
 *     ```
       [test]
       type = text
       size = 35
       class = test
       ```
   
 *  [kk76](https://wordpress.org/support/users/kk76/)
 * (@kk76)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/plugin-custom-field-template-required-fields/#post-1042776)
 * Hi Hiroaki,
 * This is great plug-in, however, I ran into some issues. I followed the same instructions,
   but when I leave the field empty, click on publish, it says empty. After I gave
   the value and click on publish, it still says empty. Please advice.
 * This is my template content:
 * [Attach]
    type = textarea rows = 4 cols = 40 tinyMCE = true mediaButton = true
   class = Attach
 * [Post As]
    type = checkbox value = Anonymous valueLabel = Anonymous output = 
   true
 * This is template instruction:
    <script type=”text/javascript”> jQuery(‘#save-
   post’).click(function() { if(!jQuery(‘.Attach’).val()) { alert(‘Empty!’); return
   false; } }); jQuery(‘#publish’).click(function() { if(!jQuery(‘.Attach’).val()){
   alert(‘Empty!’); return false; } }); </script>
 * Thank you very much!!!

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

The topic ‘[Plugin: Custom Field Template] Required fields’ is closed to new replies.

## Tags

 * [validate](https://wordpress.org/support/topic-tag/validate/)

 * 2 replies
 * 3 participants
 * Last reply from: [kk76](https://wordpress.org/support/users/kk76/)
 * Last activity: [16 years, 4 months ago](https://wordpress.org/support/topic/plugin-custom-field-template-required-fields/#post-1042776)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
