Mask form/column field

QuestionsMask form/column field
Andre asked 7 years ago

Hello. I have three questions:

– Is it possible to mask a field to look for example like this: (NN) NNNN-NNNN ? N stands for number.
– Can I define the lenght a field should have ? Like in the case above 14 chars ?
– Can I remove any unwanted char like for example: $%#^&- and so forth ?

Thanks and regards.


1 Answers
Abu Ghufran answered 7 years ago

Hello Andre,

1) Masking is not intrinsically supported.
You can however, pick input jquery id selectors, and linking them using any lib.

Most likely, you would need to code it after show form event. for e.g. if ID of element id "date"

$grid["add_options"]["afterShowForm"] = 'function(formid) { jQuery("#date").mask(); }';
$grid["edit_options"]["afterShowForm"] = 'function(formid) { jQuery("#date").mask(); }';

2) For length of field,

$col["editoptions"] = array("maxlength" => "14");

3) For removing unwanted characters, you can use some lib mentioned above to restrict entries.
You can also use client side validation before submit.

php side:

$col = array();
$col["title"] = "Total";
$col["name"] = "total";
$col["width"] = "50";
$col["editable"] = true;
$col["editrules"] = array("custom"=>true,"custom_func"=>"function(val,label){return my_validation(val,label);}");
$cols[] = $col;

js side:
function my_validation(value,label)
if (value > 100)
return [true,""];
return [false,label+": Should be greater than 100"];

Your Answer

0 + 7 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.

How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?