Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote -1 down vote accepted

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

  <Field
  ID="{GUID}"
  Overwrite="TRUE"
  OverwriteInChildScopes="TRUE"
  Name="EmailAddress"
  DisplayName="Email Address"
  Required="FALSE"
  Type="Text"
  Group="MyColumns">
    <Validation Message="Enter email like someone@example.com">=AND(ISNUMBER(FIND(&quot;@&quot;,EmailAddress)),LOWER(RIGHT(EmailAddress,4)=&quot;.com&quot;))</Validation>
  </Field>
share|improve this answer
    
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 El-Deen 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 El-Deen Apr 5 '12 at 5:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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