Form Special Caracters Validation

  • 16 August 2018
  • 2 replies
  • 10 views

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 replies

Thanks! Here is how i validate only letter and spaces 🙂

> <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>
Userlevel 7
Badge +3

Hey @PLF,

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

Best,
Hristian

Reply