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
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>