Question: Why the following script produce wrong JavaScript alert? 

```
<script type="text/javascript">   
        $('#cpassword').change(function() {
     var pass=$('#password').val;
     alert(pass);
      var cpass=$('#cpassword').val;
      alert(cpass);
    });

    </script>

```

I have two password type where i get there value and compare to notify user on the right hand of text box but error is there. Help me out! How to get the value!

Answer: 
jQuery uses the `.val()` **function** to get the value of the (first) element in a jQuery object. You're attempting to access the `val` **property** of that object. Try the following (note the `()` to indicate you're calling a function, not accessing a property):

```
$('#cpassword').change(function() {
    var pass = $('#password').val();
    alert(pass);
    var cpass = $('#cpassword').val();
    alert(cpass);
});

```
`val()` is an function, so it has to be called as `element.val()`.

Use the jQuery [documentation](http://api.jquery.com/val/).