PDA

View Full Version : TreeEditor Validation



sj137
30 May 2007, 7:18 AM
:s does anyone know where i can find information about adding vtype validation to a TreeEditor...

I searched the forum, google and the api docs but couldn't find out if /or how to set it up...
...i also could find information about the Ext.Tree.TreeEditor...?

I'm working from the dependency tree example, and i want to have a leaf node only accept digits/numbers into it's text field.

i know that the regex for numbers-only looks something like this:

/[0-9]/


Many thanks in advance,

SJ

sj137
28 Jun 2007, 2:35 AM
ok i found the treeeditor js file it was listed as the subclass of editor.js

sorry for my ignorance.

....


I also managed to prevent the user from submitting a non-number by attaching a function to the 'beforecomplete' event.



var myTreeEditor = new xt.TreeEditor(ctree, {
allowBlank:true,
blankText:'A valid number is required',
selectOnFocus:true,
revertInvalid:true
});


myTreeEditor.on('beforecomplete', function(node, value, startValue){

if ((value.match(/[0-9]+/)) || (value=='')){
return true;
}else{
return false;
}
});


this works fine except it doesn't tell the user anything informative if they've typed in a character or a space etc...

how can i make the jagged red-underline appear and a quicktip with some useful info.

Many thanks in advance.

SJ

sj137
28 Jun 2007, 4:57 AM
sorry the above doesn't quite work...

the regex is wrong it matches numbers anywhere in the string, so there could be other characters there and it will return true. :s