Solved

JQuery Validation Problem

Posted on 2013-06-25
3
218 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

726 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