On May 9, 2008, at 12:36 PM, Krz wrote:

1) When using jeditable plugin, how to add validate to the activated
input field or textarea field for preventing some malicious people
empty the data.

Ive tried frantically to get this working together. My jeditable works
fine. But im trying to include the validation. Ive tried putting the
validation function everywhere. After several combinations, I've not
got a clue to proceed. This is what I last ended up with:



I made a small change to Jeditable. Download from URL below. Jeditable will now abort submitting form if custom inputs call before submit hook returns false.

http://tinyurl.com/678scb

Word of warning. This change is EXPERIMENTAL. I am not 100% happy with it. I just wanted to help you out and this seemed a quick solution. I might do some changes on how it works after testing.

Anyways, this change enables you to write code like below:

-cut-
  $.editable.addInputType('validate', {
      element : $.editable.types.text.element,
      submit  : function(settings, original) {
          var validation_failed = true; /* Validate here... */
          if (validation_failed) {
            original.editing = false;
            $(original).html(original.revert);
            return false;
          }
      }
  });
-cut-

and then

-cut-
  $(".editable_select").editable("<?php print $url ?>save.php", {
    type   : "validate",
    submit : "OK",
  });
-cut-


--
Mika Tuupola
http://www.appelsiini.net/

Reply via email to