myForm.attachEvent("onInputChange", function(name_input, value_input){
if(name_input == 'phone'){
var v = value_input;
v = v.replace(/\D/g, "");
v = v.substring(0, 9);
v = v.replace(/^(\d{3})(\d)/g,"$1.$2");
v = v.replace(/^(\d{3})\.(\d{3})(\d)/g,"$1.$2.$3");
v = v.replace(/(\d)\.(\d{3})$/,"$1.$2");
myForm.setItemValue(name_input, v);
}
}
myForm.attachEvent("onInputChange", function(name_input, value_input){
if(name_input == 'phone'){
var v = value_input;
v = v.replace(/\D/g, "");
v = v.substring(0, 9);
v = v.replace(/^(\d{3})(\d)/g,"$1.$2");
v = v.replace(/^(\d{3})\.(\d{3})(\d)/g,"$1.$2.$3");
v = v.replace(/(\d)\.(\d{3})$/,"$1.$2");
myForm.setItemValue(name_input, v);
}
});
Thanks @lucas1, but your code caused the screen to go blank. Here’s how I implemented it:
myForm.attachEvent("onInputChange", function(name_input, value_input, inp){
if (name_input == "Phone_home"){
var v = value_input;
v = v.replace(/\D/g, "");
v = v.substring(0, 9);
v = v.replace(/^(\d{3})(\d)/g,"$1.$2");
v = v.replace(/^(\d{3})\.(\d{3})(\d)/g,"$1.$2.$3");
v = v.replace(/(\d)\.(\d{3})$/,"$1.$2");
myForm.setItemValue(name_input, v);
}
}
This is just the latest in a number of puzzling problems. I think there’s some basic flaws in the DHTMLX framework. I’m following the instructions but still having a number of problems like this one.
myForm.attachEvent("onInputChange", function(name_input, value_input, inp){
if (name_input == "Phone_home"){
var v = value_input;
v = v.replace(/\D/g, "");
v = v.substring(0, 10);
v = v.replace(/^(\d{3})(\d)/g,"$1.$2");
v = v.replace(/^(\d{3})\.(\d{3})(\d)/g,"$1.$2.$3");
v = v.replace(/(\d)\.(\d{4})$/,"$1.$2");
myForm.getInput(name_input).value = v;
}
});