Click here to Skip to main content
13,145,464 members (88,584 online)
Rate this:
Please Sign up or sign in to vote.
See more:

$('#btnSiteSave').click(function (e) {  
        var password=$('input[id$=password]').val();
        var confirmpassword=$('input[id$=cpassword]').val();
          $("#cpassword").rules("add", {
          messages: {

while click on save button i need to compare the password and confirm password.
this is the coding am tried but am not getting the output..

Pls help me to solve this.
Posted 15-Aug-12 23:22pm
Excuse me, help with what? "Not getting the output" is not informative. What did you want to get and what you actually got? Did you run it under the debugger?
ryanb31 16-Aug-12 8:09am
What is $("#cpassword")? Is it a jquery plugin? Link to it so we know what you are talking about.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You can try like this

<script type="text/javascript" src=""></script>
<script type="text/javascript">
function CheckValidation() {
     $('#Error_pspan').html("Password and Confirm Password are not matched");
                 return false;

<b>Password:</b><input type="password" name="password" id="password"  /><br/>
<span id="Error_pspan" style="color:Red; font-size:12px; font-weight:bolder;"></span><br/>
<b>Confirm Password:</b><input type="password" name="cpassword" id="cpassword"  /><br/>
<button type="Button" onclick="return CheckValidation(this);">Save</button>

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.170915.1 | Last Updated 22 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100