I'm using the Fancygrid.com Framework, and I need to validate in a Field to accept only texts and period, I'll explain. I have a field called user and the structure is: juan.cruz As you can see the field validation must accept letters and the sign (.) And also should only be written in lowercase.
I have an example of how to create a function in fancygrid and apply it to Field.
<script>
//Esta es mi función de ejemplo
var formatNumberInput = function(value){
if(/\.$/.test(value)){
return value;
}
if(/\./.test(value)){
var splitted = value.split('.');
if(splitted[1].length > 2){
splitted[1] = splitted[1].substring(0, 2);
}
value = splitted[0] + '.' + splitted[1];
}
value = parseFloat(value);
if(isNaN(value)){
value = '';
}
return value;
}
//Aqui se aplica al Field
items: [{
type: 'number',
width:72,
labelAlign: 'top',
label: 'Cap(*)',
emptyText: 'Cap',
name: 'n_capacidad',
checkValidOnTyping: true,
format: { inputFn: formatNumberInput }
}],
</script>
I pass this example to you to see how is the structure that accepts Fancygrid, I am new to use frameworks and especially in javascript, that's why I need to give me a hand to create the text function with point and only lowercase . Thanks