Title: Can&#039;t save empty fields
Last modified: August 22, 2016

---

# Can't save empty fields

 *  Resolved [Runo](https://wordpress.org/support/users/runo/)
 * (@runo)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/cant-save-empty-fields/)
 * I’m using validated fields to save a few values, but while they validate just
   fine if they have the correct data inserted, they essentially became “required”
   fields, and return validation errors when empty.
 * Maybe the issue is my regex? These are the regular expressions I’m using:
 * `^(\([0-9]{2}\))([0-9]{4,5})([0-9]{4})$`
 * `^[A-Za-z0-9_]{1,15}$`
 * The first one is so I can validate phone numbers from my country: (99)99999999
   or (99)99999999.
 * The second one is so I can validate Twitter usernames without the @.
 * Thanks in advance.
 * [https://wordpress.org/plugins/validated-field-for-acf/](https://wordpress.org/plugins/validated-field-for-acf/)

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

 *  Plugin Author [doublesharp](https://wordpress.org/support/users/doublesharp/)
 * (@doublesharp)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/cant-save-empty-fields/#post-5332301)
 * Hi [@runo](https://wordpress.org/support/users/runo/),
 * If the fields are not required then the validation shouldn’t be running against
   them. Is it possible for you to test with the new beta version? I believe this
   is corrected there as I am not able to reproduce it.
 * Thanks!
 * [Validated Field 3.4 Beta](https://wordpress.org/support/topic/validated-field-34-beta)
 *  Plugin Author [doublesharp](https://wordpress.org/support/users/doublesharp/)
 * (@doublesharp)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/cant-save-empty-fields/#post-5332306)
 * [@runo](https://wordpress.org/support/users/runo/) thought about this a bit more
   and I think I misunderstood – basically you want to make a field not required,
   but if something is entered then you want to have it validated, otherwise let
   it be empty?
 * If so you need to make your regular expression optional by putting it in a matching
   group and adding `?`:
 * `^((\([0-9]{2}\))([0-9]{4,5})([0-9]{4}))?$`
 * Check it out here: [http://regex101.com/r/fX2pL7/1](http://regex101.com/r/fX2pL7/1)

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

The topic ‘Can't save empty fields’ is closed to new replies.

 * ![](https://ps.w.org/validated-field-for-acf/assets/icon-256x256.png?rev=1116693)
 * [Advanced Custom Fields: Validated Field](https://wordpress.org/plugins/validated-field-for-acf/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/validated-field-for-acf/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/validated-field-for-acf/)
 * [Active Topics](https://wordpress.org/support/plugin/validated-field-for-acf/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/validated-field-for-acf/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/validated-field-for-acf/reviews/)

## Tags

 * [empty](https://wordpress.org/support/topic-tag/empty/)
 * [regex](https://wordpress.org/support/topic-tag/regex/)
 * [regular expression](https://wordpress.org/support/topic-tag/regular-expression/)
 * [required field](https://wordpress.org/support/topic-tag/required-field/)
 * [Validation error](https://wordpress.org/support/topic-tag/validation-error/)

 * 2 replies
 * 2 participants
 * Last reply from: [doublesharp](https://wordpress.org/support/users/doublesharp/)
 * Last activity: [11 years, 7 months ago](https://wordpress.org/support/topic/cant-save-empty-fields/#post-5332306)
 * Status: resolved