Reputation: 33966
I'm trying to get the password's length so I prevent form submition if it's too short. How is this done?
This is what I'm trying right now:
$('#registerForm input[type="password"]').val.length
Upvotes: 0
Views: 9979
Reputation: 45124
You can add an id <input id="pw" type="password">
$('#pw').val().length;
or You can add a class <input class="pw" type="password">
$('.pw').val().length;
else keep it as it is and you can get the length using jquery
$('#registerForm input[type="password"]').val().length;
Hope this will help you out. If you have any questions please don't hesitate to ask. Thanks
Upvotes: 3
Reputation: 5283
Use this you have some error in your code
$('#registerForm input[type="password"]').val().length
Upvotes: 1
Reputation: 10941
val
is a function, so you need to write val()
:
$('#registerForm input[type="password"]').val().length
Upvotes: 7
Reputation: 21130
You need to evalute val
as a function.
$('#registerForm input[type="password"]').val().length
Upvotes: 2