Is there a W3C valid way to disable autocomplete in a HTML form?

Here is a good article from the MDC which explains the problems (and solutions) to form autocompletion. Microsoft has published something similar here, as well. To be honest, if this is something important to your users, ‘breaking’ standards in this way seems appropriate. For example, Amazon uses the ‘autocomplete’ attribute quite a bit, and it … Read more

What does “for” attribute do in an HTML tag?

The <label> tag allows you to click on the label, and it will be treated like clicking on the associated input element. There are two ways to create this association: One way is to wrap the label element around the input element: <label>Input here: <input type=”text” name=”theinput” id=’theinput’> </label> The other way is to use … Read more

Warn user before leaving web page with unsaved changes

Short, wrong answer: You can do this by handling the beforeunload event and returning a non-null string: window.addEventListener(“beforeunload”, function (e) { var confirmationMessage=”It looks like you have been editing something. ” + ‘If you leave before saving, your changes will be lost.’; (e || window.event).returnValue = confirmationMessage; //Gecko + IE return confirmationMessage; //Gecko + Webkit, … Read more

Clear form fields with jQuery

For jQuery 1.6+: $(‘:input’,’#myform’) .not(‘:button, :submit, :reset, :hidden’) .val(”) .prop(‘checked’, false) .prop(‘selected’, false); For jQuery < 1.6: $(‘:input’,’#myform’) .not(‘:button, :submit, :reset, :hidden’) .val(”) .removeAttr(‘checked’) .removeAttr(‘selected’); Please see this post: Resetting a multi-stage form with jQuery Or $(‘#myform’)[0].reset(); As jQuery suggests: To retrieve and change DOM properties such as the checked, selected, or disabled state of … Read more

Uploading both data and files in one form using Ajax?

The problem I had was using the wrong jQuery identifier. You can upload data and files with one form using ajax. PHP + HTML <?php print_r($_POST); print_r($_FILES); ?> <form id=”data” method=”post” enctype=”multipart/form-data”> <input type=”text” name=”first” value=”Bob” /> <input type=”text” name=”middle” value=”James” /> <input type=”text” name=”last” value=”Smith” /> <input name=”image” type=”file” /> <button>Submit</button> </form> jQuery + … Read more

What’s the proper value for a checked attribute of an HTML checkbox?

Strictly speaking, you should put something that makes sense – according to the spec here, the most correct version is: <input name=name id=id type=checkbox checked=checked> For HTML, you can also use the empty attribute syntax, checked=””, or even simply checked (for stricter XHTML, this is not supported). Effectively, however, most browsers will support just about … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)