Survey: How Well Do You Use Your Phone for Productivity
If you follow this site you know that we like to execute surveys about various digital topics. When we do this we make the survey and the survey results available to all our readers. After you take the survey you will be given the opportunity to subscribe to receive results from our surveys.
jQuery(function($) {
$('form#survey-2').bind('submit', function() { $('#submit').attr("disabled", true); });
$(':input.Other').bind('click', function() { $(this).prev().prev().attr("checked", "checked"); });
// set the default survey error handler $.fn.form.setErrorHandler('default', function(errors) { var form = $(this);
// remove the error messages form.find('.Widget div.Error').remove();
// foreach error, insert them $.each(errors, function(errorIndex, error) { // fields with the same name represent radio and checkboxes var fieldsWithSameName = form.find('[name="' + error.field.attr('name') + '"]');
// put a error message after the widget title, but do it only once for each widget if (fieldsWithSameName.index(error.field) == fieldsWithSameName.length - 1) { //error.field.closest('.Widget').find('label:first').after('
'); error.field.closest('.Widget').find('label:first').after('
'); } });
// focus the first error field errors[0].field.focus();
// and alert the first error message alert(errors[0].message); $('#submit').removeAttr("disabled"); });
// initialize the survey validator $('#survey-2').form().init({ errorClass : 'Required' });
$('#survey-2').form().getFields().each(function() { var field = $(this); var label = field.closest('.Widget').find('label:first'); flabel = label.text(); flabel = flabel.replace(" \*","\""); field.form().setErrorMessage('required', 'The "' + flabel + ' field is required.'); });
// language pack the error messages $('#survey-2').form().setErrorMessage('required', "This field is required.");
// "Other" fields must not be empty if their corresponding // radio button is checked $('#survey-2 :input.Other').form().setDependency(function(field) { if ($(this).siblings(':radio:checked, :checkbox:checked').length && $.trim($(this).val()) == '') { $('#submit').removeAttr("disabled"); return false; } return true; }, "Please type an answer in the text box next to the checked field.");
// disabling button on submit //alert( $('.required:first').form().getErrorMessage() ); });
The world really amazing!