How To Clear An HTML File Input Field

Author: , July 19th, 2012

An HTML file input can’t be cleared by normal means (i.e. setting the value to null or an empty string) because of browser security restrictions. In most browsers, setting a null value attribute either will have no effect or cause an error. Creating a new element that clones the old element and swap the two […]

How To Validate Passwords Using jQuery

Author: , October 19th, 2011

The ability to validate BEFORE a form is submitted greatly reduces end-user frustration by telling the user immediately what the issue is. The jQuery Validation plugin does just that. Here is a link to the plugin’s home page: This is a simple recipe for doing custom password validation: In the html head

In […]

How To Create An Input Field Watermark Using jQuery

Author: , September 20th, 2011

Here is a VERY simplistic watermark code snippet. It has the distinct disadvantage of submitting the watermark string as the field value, and does not set the initial field value either…YMMV…

How To Determine The Parent Form Element Of An Input

Author: , April 14th, 2011

Original Post: Native DOM elements that are inputs also have a form attribute that points to the form they belong to: var Form = element.form; alert(jQuery(Form).attr(‘name’)); Use the jQuery closest() function for NON-INPUT elements: var $form = jQuery(element).closest(‘form’); alert($form.attr(‘name’)); Another cool post:

How to deal with broken form <input type=image> in IE

Author: , October 22nd, 2009

[code] <form method="post"> <input type="hidden" name="myName" value="" /> <input type="image" name="submit" value="42" src="icon.gif" onclick="this.form.myName.value = this.value"> </form> [/code]