jQuery - store items in temporary storage using hidden input
Store items in temporary storage using hidden input
Store items in temporary storage using hidden input
A script with jQuery to validate e-mail address an a form. It changes the class of the form to 'error' and disable the send button if not valid.
A short script for jQuery that validates two password fileds so they have the same value and a minimum length.
This is how you can on change and on key press or actually Key up event call an action after a certain amount of seconds, in this case 2 sec (2000 milliseconds). Here I use it on a textarea in Drupal 6 with no text editor. I want to call a function that calculates estimated execution time based on given number of rows in the textarea.
Here is how you can toggle an action depending on a checkbox is marked or not. In this case added to a Drupal 6 form item checkbox.
This is a jQuery script for Drupal forms changing the select form class to the same as the selected option item. I use the change event on select item because Chrome doesn't allow click event on option tags.
<?php
$script = '$(document).ready(function() {
$("select.bj-status-selector").change(function(){
var optClass = $(this).children(":selected").attr("class");
$(".bj-status-selector").removeClass().addClass("form-select bj-status-selector " + optClass);
});
});
';
drupal_add_js($script, 'inline', 'footer');
?>
This script adds a month-year picker to a text field, and works better than a modification of jQuery datepicker.
<?php
drupal_add_js(drupal_get_path('module', 'jquery_ui') .'/jquery.ui/ui/jquery.mtz.monthpicker.js');
$sub_script = "$(document).ready(function () {
$('.add-datepicker-y-m').monthpicker({
'pattern': 'mm/yyyy'
})
}); ";
drupal_add_js($script, 'inline', 'footer');
?>
Source: https://github.com/lucianocosta/jquery.mtz.monthpicker
This is how you can add a monthly datepicker modification in jQuery in Drupal and use numeric date format like yyyymm.
This version uses the format of yyyymm e.g. '201112' for Dec 2011
This is some idea on how you can add a datepicker programmatically with the jquery_ui module. This code is not working as it is, its just some code I have cut out from my code. You have to match the form id in the jquery script as the drupal form creates. Look for edit-from, edit-to, edit-month in the script. I have here two alternative jquery scripts. And you find more scripts at the link to jqueryui.com below.