Posts

Showing posts from May, 2010

How to validate default values in a form ,- jquery validation plugin

I had a form which contained default values in the text boxes. ex: The first Name box has value 'Your Name' in it. But when onfocus, the text was cleared for user input. As I was using Jquery validation plugin i wanted to handle this scenario using jquery. Below is my question and the answer i came up with. http://stackoverflow.com/questions/2733922/jquery-validation-how-to-ignore-default-values-when-validating-mandatory-fields

jquery validation plugin and IE8 - 'jQuery.event.special.focusin' is null or not an object

I recently was using jquery validation plugin for form validation. It worked perfect on Firefox and Chrome. But when I tested on IE 8 , it did not work. The form submitted without any validation. using the inbuilt Javascript debugger for IE 8 (press F12 to activate it), I noticed the error 'jQuery.event.special.focusin' is null or not an object. I ran the sample that came with the jquery.validation plugin and it seemed to work on IE8 without any issues, the only thing I noticed was that the reference for jquery.js and the jquery.validation plugin were right below each other. So I did the same, I moved the jquery.js reference from master page to the page where the validation plugin was used and the validation worked fine! <script type="text/javascript" src="assets/scripts/jquery-1.2.6.min.js"></script> <script src="assets/scripts/jquery.validate.min.js" type="text/javascript"></script>

window.location does not work on Firefox

I had a scenario wherein a user clicks a button and a client side javascript function executes and redirects user to another page. I used window.location.href for redirection, but this did not work in firefox. Having looked up at other sites, the suggestion was to use window.location but this did not work still. I then realised that the problem was the way the javascript function was called in the onclick event of the button and it required a return false; to get it working. Below is the code sample, the button has a return false, which prevents the form from submitting to itself and enable re-direction. <script language="javascript" type="text/javascript"> function GoToRegistration() { var url = "http://www.lotussoftwaremall.com/" window.location=url; } </script> <input name="submit" type="image" src="submitbutton.png" onclick="GoToRegistration(); return false ;" width="80" he