Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6075753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:31:46+00:00 2026-05-23T10:31:46+00:00

I’ve created my model using Entity Framework, and I’ve created a basic website in

  • 0

I’ve created my model using Entity Framework, and I’ve created a basic website in MVC3 to allow me to edit items within the database. So far it works fine, but I wanted to add a regular expression to ensure that the contents of one of the form fields always contains a particular HTML element.

What I have in my model so far, for the property in question, is as follows:

[Required]
[AllowHtml]
[DataType(DataType.MultilineText)]
[RegularExpression("^.*(<p>).*$", ErrorMessage = "Must contain <p> element")]
public string Text { get; set; }

I’ve tried variations on the RegularExpression attribute shown above, but nothing seems to work. What I essentially want to do is make sure that the text in the text area for the above property always contains at least one <p> element.

Admittedly I’m not very strong on regular expressions, so I’m probably way off the mark. Any pointers? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:31:47+00:00Added an answer on May 23, 2026 at 10:31 am

    Try this, which makes sure that there is an opening and closing <p> tag (so they can’t just do <p> without also doing </p>).

    [RegularExpression(@"<p\b[^>]*>(.*?)</p>", ErrorMessage = "Must contain <p> element")]
    

    There is a handy explanation here, which will help you customise the example should you wish to.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've created a database model with model-first method using Entity Framework 4.0. I then
Using Zend Framework, I've created a Model to insert a record into a database.
I have created a very simple Entity Framework 4.0 model using VS2010 Professional. Ignore
I have a edmx file created using the entity entity framework model. Whenever I
I created an Entity Framework model based on an existing database, then generated the
Using Microsoft's designer for the Entity Framework (v3.5), I have created an Entity Model
When using the Entity Framework there are basically two ways to create your model.
I'm using Entity Framework 4 in my project. The Framework has created its own
I have created a repository that is returning data from my database using Entity
I have developed a project using MVC3 and Code first Entity Framework 4.0 as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.