سؤال

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

  <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>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى sharepoint.stackexchange
scroll top