Converting json results to a date



var date = new Date(parseInt(jsonDate.substr(6)));



var x = [{
    "id": 1,
    "start": "\/Date(1238540400000)\/"
}, {
    "id": 2,
    "start": "\/Date(1238626800000)\/"

var myDate = new Date(x[0].start.match(/\d+/)[0] * 1);






Add maxlength on textArea using jQuery

The Low Down

The maxlength attribute limits the number of characters that an <input> or<textarea> can accept. The maxlength attribute on textarea is new in HTML5.

  • Works for GUI-less inputs like text, email, url, search, tel and password.
  • Upon data entry, browsers will not permit the user to enter more than the characters defined by the value of the maxlength attribute: cutting off the text as-you-type and truncating pasted text. This can lead to bad user experience.
  • maxlength does not limit placeholder length.
  • If a preset value is included with a value that has more characters than the allowed length, a validation error will not be thrown. However, if that preset value is edited, yet is still longer than the allowed length, the element will become invalid, matching the :invalid pseudoclass selector, and will be prevented from being submitted in both Opera and IE10+, which both display the tooLong validity error message.
  • IE 9 reported support on both inputs and textareas but only works on inputs.



The textArea “maxlength” attribute is supported in HTML 5, the problem is not all browsers support HTML 5, especially, the old IE.


jQuery Example

A jQuery example to implement the “maxlength” effect on a textarea field.

<script language="javascript" type="text/javascript"
<script language="javascript" type="text/javascript">

    $(document).ready( function () {

	maxLength = $("textarea#comment").attr("maxlength");
" + maxLength + " remaining
); $("textarea#comment").bind("keyup change", function(){checkMaxLength(, maxLength); } ) }); function checkMaxLength(textareaID, maxLength){ currentLengthInTextarea = $("#"+textareaID).val().length; $(remainingLengthTempId).text(parseInt(maxLength) - parseInt(currentLengthInTextarea)); if (currentLengthInTextarea > (maxLength)) { // Trim the field current length over the maxlength. $("textarea#comment").val($("textarea#comment").val().slice(0, maxLength)); $(remainingLengthTempId).text(0); } }
</script> </head> <body> <h1>TextArea maxlength with jQuery</h1> <textarea id="comment" maxlength="10" rows="10" cols="60" ></textarea> </body> </html>








Asc/Desc tooltip on sorting columns?


if (($(this).hasClass(‘sorting’)) || ($(this).hasClass(‘sorting_desc’))) {
$(this).attr({title: ‘Sort Ascending’});
} else {
$(this).attr({title: ‘Sort Descending’});




Button type “button” vs. “submit”

The type of the button. Possible values are:

  • submit: The button submits the form data to the server. This is the default if the attribute is not specified, or if the attribute is dynamically changed to an empty or invalid value.
  • reset: The button resets all the controls to their initial values.
  • button: The button has no default behavior. It can have client-side scripts associated with the element’s events, which are triggered when the events occur.



jquery detect textbox value change NOT based on user input

var $myText = $(“#myText”); $“value”, $myText.val()); setInterval(function() { var data = $“value”), val = $myText.val(); if (data !== val) { $“value”, val); alert(“changed”); } }, 100);