Assignment #3 – Form Validation

Objectives

To create your first MVC form using a database

Assignment

You will be duplicating the form you created in COP4813 here COP 4813 Assignment 3 only this time using MVC and server side programming. To do this you will first create a data model based on the data fields required by the form see this link for a quick overview (you are still expected to view the video and other materials for a more in depth understanding of models). This is relatively easy to do in Visual Studio using your default MVC application. This model will also be used to create both the default controller and view. In the previous link you saw creating a model – here are the steps to make the controller and the view. You data is all 1:1 relationship so is very simple to work with and manipulate. You will be making changes to the model and the view for this assignment. You will have questions and I expect these questions to make it to the class discussion board. In reality handing the validation server side is actually easier than writing the Javascript to do the validation – as most of it will be generated automatically after you learn to set property attributes.

Assignment from COP4813 that you will be duplicating for this assignment.

You are going to create an input form using HTML5 and Javascript. This input form will not submit any database to the server (you learn to do this in COP4834). It will validate and collect information from the user and go to a confirm page that displays the information entered and allows the user to confirm that the information is correct. Below are all the input form fields and the validation required.

It is up to you (the designer) how you present the information request. For example in entering a date you can have a single text box, or you can have multiple boxes with drop down choices. You do, however, have to validate the data to make sure it meets all validation rules.

Field 
Validation 
Name 
 The user must enter a first and last names. These cannot be blank. You may use a single text box, but must check for 2 names, or use 2 text boxes.
Address 
The user must enter a valid mailing address that follows address rules. A city, state, and zip code must also be included as part of the address. You can use multiple text boxes – or a single one. You must still validate all elements.
Phone Number 
A full 10 digit phone number must be entered (includes area code).  Use an input mask to make the entry easy for the user. Read StackOverflow responses to creation of input masks using jQuery
Email Address 
User must enter a correctly formatted email address  [email protected] – 
Birth DateUser must enter a valid birthday, make sure to check format and also date – if dates are unreasonable (like in the future) give a warning.
Message 
The user will enter a free text message, you should have a multi-line text entry area for the message  
Confirmation 
A simple confirmation method to ensure that the fields are not filled out by a machine, you can use a captcha or simple security question (like what is the last name of the current president)

Once the user enters all this information in the form and hits submit, you will present the information and allow the user to confirm that it is all correct. The user should not be able to enter invalid data or leave fields blank.

Information

Here is what you will need to successfully complete this assignment. You can use the published default web site from Assignment 2 – Publishing to the Web and simply add the code for the form.

You should go through the MVA short class on MVC – https://mva.microsoft.com/en-US/training-courses/introduction-to-asp-net-mvc-8322 if you did not go through it for the last assignment. 

In addition you will want to get started learning Entity Framework, though there is no requirement for EF for this assignment – many of my samples and code will be using EF. https://mva.microsoft.com/en-us/training-courses/implementing-entity-framework-with-mvc-8931 

If you have the basic understanding of at least MVC – you are ready to start this project. I have created a lecture that takes you through the first part of this in 16 minutes and will give you what you need to be able to complete this project successfully.

Estimated Completion Time

So I did most of this in 16 minutes in the lecture. It will take you longer and you will want to make it through the MVA video segments. Allot about 10 hours to go through everything and truly learn how to do this.

Supporting Lectures 

Implementing Entity Framework with MVC https://mva.microsoft.com/en-us/training-courses/implementing-entity-framework-with-mvc-8931

Here is a 3 part video series I created to help with this Lecture – Model Based Development in MVC Part 1

Questions and Answers

There should be questions associated with this – I copy the best from discussion boards and put here to help you work your way through this assignment.

External Resources

Microsoft Virtual Academy Short Course on MVC – https://mva.microsoft.com/en-US/training-courses/introduction-to-asp-net-mvc-8322 

Implementing Entity Framework with MVC – https://mva.microsoft.com/en-us/training-courses/implementing-entity-framework-with-mvc-8931 

Lecture – Model Based Development in MVC Part 1

Using Property Attributes in an MVC Model – https://www.asp.net/mvc/overview/older-versions-1/models-data/validation-with-the-data-annotation-validators-cs 

Adding a Model to an MVC Project – https://www.asp.net/mvc/overview/getting-started/introduction/adding-a-model (follow next links on this for more information)

Using attributes for Validation – https://msdn.microsoft.com/en-us/library/cc668224.aspx 

Grading Criteria

A fully working for that validates input and stores in the database for later retrieval is worth a full 10 points. Incomplete validation of any field is worth 1 point off.