I want to create a function which does not allow updating a record if it has special characters.
This is the way I'm doing it. I use a RexExp and I enter the characters:
onItemUpdating: function(args)
{
var grupo_promocion;
var c_barra;
var pattern = new RegExp(/^[^!@"#$%&\/()]*$/);
c_barra=args.item.c_barra;
grupo_promocion=args.item.grupo_promocion;
if (args.item.grupo_promocion === null || args.item.grupo_promocion == "" ) {
grupo_promocion="";
}
if(pattern.test(document.getElementById("grupo_promocion"))){
alert("No se permite ingresar caracteres como @ # & %")
args.cancel = true;
}else{
updategpromocion(c_barra,args.item.grupo_promocion);
alert("Se actualizo el grupo de promoción correctamente")
}
}
then I put the condition using the test function, but if I enter letters and numbers it also generates the alert and does not update me.
Do I need any other condition?