Mask form/column field

QuestionsMask form/column field
Andre asked 11 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.

Andre

1 Answers
Abu Ghufran answered 11 years ago

Hello Andre,

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

http://digitalbush.com/projects/masked-input-plugin/
https://github.com/RobinHerbots/jquery.inputmask

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(); }';
$g->set_options($grid);

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:
<script>
function my_validation(value,label)
{
if (value > 100)
return [true,""];
else
return [false,label+": Should be greater than 100"];
}
</script>

Your Answer

14 + 17 =

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?