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!
jQuery uses the
.val()function to get the value of the (first) element in a jQuery object. You’re attempting to access thevalproperty of that object. Try the following (note the()to indicate you’re calling a function, not accessing a property):