/ Sitecore

Sitecore Experience Forms - Bad JSON escape sequence


Sitecore on form submission, submit action fails. We had multiple submit action. Save action worked and rest of all the actions failed. We also had a custom submit action that was failing too. The issue occurred only on Content Delivery but worked on Content Authoring.

Exception Details

ERROR [Experience Forms]: Bad JSON escape sequence: \d. Path 'regularExpression', line 1, position 31.
Exception: Newtonsoft.Json.JsonReaderException
Message: Bad JSON escape sequence: \d. Path 'regularExpression', line 1, position 31.
Source: Newtonsoft.Json
at Newtonsoft.Json.JsonTextReader.ReadStringIntoBuffer(Char quote)
at Newtonsoft.Json.JsonTextReader.ReadStringValue(ReadType readType)
at Newtonsoft.Json.JsonTextReader.ReadAsString()
at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
at Sitecore.ExperienceForms.Mvc.Models.Validation.ValidationElement`1.TryParse(String value, TParameters& target)


  1. Open content editor Using your master database, navigate to the "/sitecore/system/Settings/Forms/Validations/Phone Number Validator" item
  2. In the Parameters field change the following from 'a' to 'b' (add an additional backslash in front of existing backslashes) as follows:
    a. {"regularExpression":"^(1?(-?\d{3})-?)?(\d{3})(-?\d{4})$"}
    b. {"regularExpression":"^(1?(-?\d{3})-?)?(\d{3})(-?\d{4})$"}
  3. Save and publish this item to the web database
  4. Switch to the web database in Sitecore Desktop and make sure the field updated correctly.

Note: I have to Republish the item for the change to work.

Thanks for Sitecore Support to find this wierd issue and provide a solution.