I'm a jquery newbie and am trying to use it in a simple web application. This application has a controller servlet that forwards the request to a 'login.jsp' page by default. In the login.jsp page, I used Jquery for the hover effect on the submit button. If I name my file 'login.html', it works absolutely fine. If I rename it to 'login.jsp', the javascript is not working. I see the following error in Firebug console: syntax error [Break on this error] <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"\n"
My login.jsp file: > <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" > "http://www.w3.org/TR/html4/loose.dtd"> > <html> > <head> > <meta http-equiv="Content-Type" content= "text/html; > charset=iso-8859-1"> > <title> > Login Page > </title> > <link rel=stylesheet href="../css/qtool.css" type="text/css" > media=screen> > <script type="text/javascript" src="jquery-1.3.2.min.js" ></script> > <script type="text/javascript" src="login.js" ></script> > </head> > <body> > <div id="container"> > <div id="box" class="loginBox"> > <form method='POST'> > <input type="text" name="user" id="user" size=10/> > <br /> > <input type="password" name="pwd" id="pwd" size=10/> > <br /> > <input type="image" name="submit" id="submit" /> > <input type="hidden" name="action" value="login"/> > </form> > </div> > </div> > </body> > </html> > My login.js file: > $(function() { > //Load the default button > $('input#submit').attr('src', '../images/new/loginButton.png'); > > //When mouse hovers on button, show button_hover.png, else show > button.png > $('input#submit').hover(function() { > $(this).attr('src', '../images/new/loginButton_hover.png'); > }, function() { > $(this).attr('src', '../images/new/loginButton.png'); > }); > > //Set the max length of the user ID text box > $('input#user').attr('maxlength', '8'); > > //Set the max length of the password box > $('input#pwd').attr('maxlength', '8'); > > $('input#submit').click(function() { > return validateInput(); > }); > > > function validateInput() { > if (($('#user').val() == null) || ($('#user').val() == '')) { > $('#warning').remove(); > $(' ../images/warning.png ').insertAfter('#user'); > $('input#user').focus(); > return false; > }; > > if (($('#pwd').val() == null) || ($('#pwd').val() == '')) { > $('#warning').remove(); > $(' ../images/warning.png ').insertAfter('#pwd'); > $('input#pwd').focus(); > return false; > }; > }; > }); > I have the files 'login.jsp', 'login.js', 'jquery-1.3.2.min.js' under the webapps/QT/jsp/ folder. I think this might be a small problem, but am unable to fix it. Hope someone can help. -- View this message in context: http://www.nabble.com/Jquery-not-working-in-jsp-tp23345068s27240p23345068.html Sent from the jQuery General Discussion mailing list archive at Nabble.com.