Solved

JQuery Validation Problem

Posted on 2013-06-25
3
219 Views
Last Modified: 2013-07-02
NuGet shows that the JQuery Validation in installed and I created the JQuery Validation in the View the way I thought it needed to be done but I cannot get it to run. All of the other fields have Validations so I only need to ensure that the user retypes the password correctly in the field with <input id="txtCheckPassword" type="text" />

Does anyone see the reason why the JQuery Validation will not run? (File attached below)
CreateAccountView.docx
0
Comment
Question by:AmbassadorSpock
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 25

Accepted Solution

by:
kevp75 earned 500 total points
ID: 39278215
You are using the same field ID twice.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 39278287
Here is the code in readable format, wrapped in [ code]...[ /code] as we prefer it

@model RescueFormsAdministration.Models.CreateAccountViewModel

@{
    ViewBag.Title = "Create";
}

<h2>Create</h2>
<script>
$.validator.setDefaults({
	submitHandler: function() { alert("submitted!"); }
});

$().ready(function() {
	// validate signup form on keyup and submit
    $("#CreateAccount").validate({
		rules: {
		    txtCheckPassword: {
				required: true,
				minlength: 5,
				equalTo: "#DataModel_Password"
			}
		},
		messages: {
			txtCheckPassword: {
				required: "Please provide a password",
				minlength: "Your password must be at least 5 characters long",
				equalTo: "Please enter the same password as above"
			}
		}
	});
});
</script>

@using (Html.BeginForm("Create", "Accounts", FormMethod.Post, new { id = "CreateAccount" }))
{
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Account</legend>

		@Html.Partial("_CreateOrEdit", Model)

        <table style="width:100%">
    <!-- User Name and Password -->
    <tr>
        <td class="editor-label">
            @Html.Label("User Name")
        </td>
    </tr>
    <tr>
        <td class="editor-field">
            @Html.TextBoxFor(model => model.DataModel.UserName, new { style = "width:30%" })
            @Html.ValidationMessageFor(model => model.DataModel.UserName)
        </td>
    </tr>
    <tr>
        <td class="editor-label">
            @Html.Label("Password")
        </td>
    </tr>
    <tr>
        <td class="editor-field">
            @Html.TextBoxFor(model => model.DataModel.Password, new { style = "ModelStyle" })
            @Html.ValidationMessageFor(model => model.DataModel.Password)
        </td>
    </tr>
        <td>
            @Html.Label("Retype Password")
        </td>      
    <tr>
        <td>
            <input id="txtCheckPassword" type="text" />
        </td>
    </tr>
</table>
        <p>
            <input type="submit" value="Create" Name="btnSubmit" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

Open in new window

0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 39278290
Do you include the jQuery library in the head too?
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question