I have field called "program email" and this field is an email and part of page layout. what is the recommended way to validate that field to make sure that it is a valid email format and disable saving the page when the user enter invalid email format


You can use column validation on the site column associated with the page layout. You can edit the site column to add column valiation. Below shows example formula to check text field with @ and .com at the end.

=AND(ISNUMBER(FIND("@",[Email Address])),LOWER(RIGHT([Email Address],4)=".com"))

If you are using visual studio to deploy the field used in the content type of your page layout, try below

  DisplayName="Email Address"
    <Validation Message="Enter email like someone@example.com">=AND(ISNUMBER(FIND(&quot;@&quot;,EmailAddress)),LOWER(RIGHT(EmailAddress,4)=&quot;.com&quot;))</Validation>
  • Thanks for your reply. now the email validation is working fine. I have one more question this validation will fire even when the field is empty do you know how to make it fire only when the field not empty – Hossam Barakat Apr 5 '12 at 5:12
  • I have figured it out. it can be done using the following equation code =IF(LEN(Email)=0,TRUE,AND(ISNUMBER(FIND("@",Email)),LOWER(RIGHT(Email,4)=".com"))) code – Hossam Barakat Apr 5 '12 at 5:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.