Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
krishna sapkal
Courses Plus Student 33 Points$password.val(' ') is not a function
jquery code-
var $id = $('#user_id');
var $password = ('#user_password');
function validate (){
if($id.val().length!=8 || $password.val().length!=8){
$('.warning').show();
}
}
$('#btn').click(function(){
if($id.val().length!=8 || $password.val().length!=8)
$('.warning').show();
$id.val('');
$password.val('');
return false;
});
html code
</div>
<div class="form-card">
<p class="trial-banner basic">Get Started</p>
<div class="texfields">
<input class="input-text input-text placeholder-processed" type="text" name="user_id" placeholder="Roll Number" id="user_id">
<input class="input-text input-text placeholder-processed" type="password" name="user_password" placeholder="Password" id="user_password">
<button name="button" class="btn" id="btn">
<span>Log In</span>
</button>
</div>
1 Answer
Steven Parker
243,658 PointsLooks like there's some parts missing from your code, but that might be because you forgot to blockquote it.
But in case they are not just blockquote issues:
- you are using JQuery but it's not clear that you have included it
- there's no closing tag for your button
- your script operates on elements with the class warning, but there aren't any in the HTML
- there's no closing tag for your outer DIV (form-card)
- you defined a validate() function but never use it (but replicate it inside the click handler)