Question

Need some help making the 2nd line of this code functional, need the [Compare] function to...

Need some help making the 2nd line of this code functional, need the [Compare] function to validate the confirm email as the same as email.

[Required] [EmailAddress] public string Email { get; set; }

[Required] [DisplayName("Confirm Email")] [Compare] public string ConfirmEmail { get; set; }

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Dear Student ,

As per the requirement submitted above , kindly find the below solution.

Here a new web application in asp.net with C# is created using Visual Studio 2017 with name "MVCApp".This application contains a below model class.

Sample.cs :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;

namespace MVCApp.Models
{
public class Sample //C# class
{
//Email
[Required] [EmailAddress] public string Email { get; set; }

//ConfirmEmail
[Required]
[DisplayName("Confirm Email")]
[Compare(nameof(Email),ErrorMessage ="Email Mismatch")]
public string ConfirmEmail { get; set; }
}
}

======================================================

Output : Run application using F5 and will get the screen as shown below

Screen 1 :When controller and views are added then will get the screen as shown below

Screen 2:When email and confirm email is mismatch

NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.

Add a comment
Know the answer?
Add Answer to:
Need some help making the 2nd line of this code functional, need the [Compare] function to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Hey Guys I am doing a project and need some help with code in HTML and...

    Hey Guys I am doing a project and need some help with code in HTML and PHP. I need a form made in HTML that can be sent to a specific email through PHP. For some reason the info is not getting sent to my email, even though it says that it was sent. I have some source code here: <?php if(isset($_POST['submit'])) { $name = $_POST['name']; $email = $_POST['email']; $subject = $_POST['subject']; $message = $_POST['message']; $email = mail('MY_EMAIL', $subject, $message,...

  • DUE TODAY: Need Help with my ASP NET quiz 1.) [________________] attribute is added to ensure...

    DUE TODAY: Need Help with my ASP NET quiz 1.) [________________] attribute is added to ensure two properties on a model object have the same value. 2.) What is the purpose of the following annotation? [StringLength (120, MinimumLength=10)] public string Firstname {get; set} public string Lastname {get;set;} a. FirstName and LastName can be of length 160 characters b. FirstName and LastName can be of length 10 characters c. FirstName can be of length between 10 and 120 character s d....

  • I need help with adding comments to my code and I need a uml diagram for...

    I need help with adding comments to my code and I need a uml diagram for it. PLs help.... Zipcodeproject.java package zipcodesproject; import java.util.Scanner; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; public class Zipcodesproject { /** * @param args the command line arguments */ public static void main(String[] args) { Scanner input=new Scanner(System.in); BufferedReader reader; int code; String state,town; ziplist listOFCodes=new ziplist(); try { reader = new BufferedReader(new FileReader("C:UsersJayDesktopzipcodes.txt")); String line = reader.readLine(); while (line != null) { code=Integer.parseInt(line); line =...

  • I need help with this code This is what I need to do: Implement the Stack...

    I need help with this code This is what I need to do: Implement the Stack Class with an ArrayList instead of an array, including the following functions: • empty • push • peek • pop • overrided toString( ) function which returns all of the stack’s contents Things to note: • You no longer need a size. • You no longer need to define a constant DEFAULT_CAPACITY. Since ArrayLists grow dynamically. • Whenever possible, use ArrayList functions instead of...

  • Hello, I need some help creating this class in Java. This is for a larger project....

    Hello, I need some help creating this class in Java. This is for a larger project. I am using Eclipse if that helps 1. Create a class named State that will store information about a state and provide methods to get, and set the data, and compare the states by several fields. a. Fields: Name, Capital City, Abbreviation, Population, Region, US House Seats b. Constructor c. Get and set methods for each field d. Compare method to compare State objects...

  • Hey everyone, I need help making a function with this directions with C++ Language. Can you...

    Hey everyone, I need help making a function with this directions with C++ Language. Can you guys use code like printf and fscanf without iostream or fstream because i havent study that yet. Thanks. Directions: Write a function declaration and definition for the char* function allocCat. This function should take in as a parameter a const Words pointer (Words is a defined struct) The function should allocate exactly enough memory for the concatenation of all of the strings in the...

  • I need help running this code. import java.util.*; import java.io.*; public class wordcount2 {     public...

    I need help running this code. import java.util.*; import java.io.*; public class wordcount2 {     public static void main(String[] args) {         if (args.length !=1) {             System.out.println(                                "Usage: java wordcount2 fullfilename");             System.exit(1);         }                 String filename = args[0];               // Create a tree map to hold words as key and count as value         Map<String, Integer> treeMap = new TreeMap<String, Integer>();                 try {             @SuppressWarnings("resource")             Scanner input = new Scanner(new File(filename));...

  • Need some help with this UNIX problem: Write a single line UNIX command to mail only...

    Need some help with this UNIX problem: Write a single line UNIX command to mail only the process ID of running Java program test to the email [email protected]

  • Need some help on the following problem in java. I have to modify the code I...

    Need some help on the following problem in java. I have to modify the code I written so far(below) to do the following three things: a). Write a method called diagnostics that occasionally throws any one of the exceptions you have created depending on the values generated by a random-number generator. b). Write a method called display that calls diagnostics and provides exception handlers to display a message when an exception occurs. Otherwise, if an exception does not occur, method...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT