clientIO / JointJS_plus

JointJS+ support
4 stars 9 forks source link

Input validation in Inspector #39

Closed DavidDurman closed 9 years ago

DavidDurman commented 9 years ago

In some text text input fields on the Inspector I would like to validate the input against some regexp. This can be done either via the HTML 5 pattern attribute in a fashion similar to this:

attrs: {
    input: {
        pattern: '[_a-zA-Z][_a-zA-Z0-9]*',
        required: 'required'
    }
}
--- joint.ui.inspector.js    (revision 1013)
+++ joint.ui.inspector.js    (working copy)
@@ -1155,6 +1155,11 @@
     onChangeInput: function(evt) {

         var $input = $(evt.target);
+
+        if (! $input[0].validity.valid) {
+          return;
+        }
+
         var path = $input.attr('data-attribute');

         if (this.options.live) {

Or with some custom solution, for example by providing a custom validation function in the inspector options object.

kumilingus commented 9 years ago

Fixed. validateInput option added.

fehmi commented 6 years ago

how can use validateInput can you write an example please