Form Special Caracters Validation


#1

Hi, im receiving leads with a special caracter ("+") in his names and this is corrupting my SQL process related with this landing page (attached below)
There is any possibilitie that i can develop a script that doesnt allow to put this caracters into the form?

Thanks!


#2

Hey @PLF,

Here is a relevant thread from the community that deals with custom validation.

Best,
Hristian


#3

Thanks! Here is how i validate only letter and spaces :slight_smile:

> <script>
>   
>   lp.jQuery(function($) {
>   
>     // Config
>     var ruleID = 'myCustomRule';
>     var field = 'nombre';
>     var message = 'Por favor, evita colocar signos en tu Nombre';
>   
>     var rules = module.lp.form.data.validationRules[field];
>   
>     $.validator.addMethod(ruleID, function(value, field) {
>   
>       // Replace this with any expression you like. It should evaluate to true
>       // if the field is valid and false if invalid. This example adds a 
>       // rule that the user must enter 'I accept' exactly into the field.
>     	var valid = ( /^[a-zA-Z\s]*$/.test(value) ); 
>   
>       return valid || (!rules.required && !value);
>     }, message);
>   
>     rules[ruleID] = true;
>     
>   });
> </script>