Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • James 251 posts 1169 karma points
    Jul 24, 2014 @ 15:24
    James
    0

    Creating A Contact Form Using SystemWeb Validation

    Hi all,

     

    I am trying to build a contact form using validation that i learned whilst creating standard razor webpages as below:

     

    Validation.RequireField("captchaCheck", "Please enter your answer here.");

        Validation.Add("name",

         Validator.Required("Please provide your name."));

        Validation.Add("email",

            Validator.Required("Please provide your email address."),

            Validator.Regex(@"^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$",

            "Invalid format for your email address."));

        Validation.Add("subject",

            Validator.Required("Please provide a subject for your message."));

        Validation.Add("message",

            Validator.Required("Please input your message."),

            Validator.StringLength(4000, 0, "No more than 4000 characters."));

     

    This is the code that sits above my contact form in an if(ispost) statement.

     

    There is red underlines on the .required .add .isvalid after the "validation" declaration.

     

    I cant right click and add a namespace to resolve this.

     

    How do i solve this ?

     

    Kind regards.

     

  • James 251 posts 1169 karma points
    Jul 24, 2014 @ 15:35
    James
    0

    Please ignore my regex its from an old project. Trying to find a way to plug in a quick and easy contact form.

Please Sign in or register to post replies

Write your reply to:

Draft