Validation of inputs shows error only in case if it's empty

Hello guys! 

Validation of inputs shows error only in case if it's empty, not in case if the type is invalid. can anyone help?

Hi,

can you give an example of the type of field and type you are trying to enter? Because depending on the type of field, it will accept insertion of distinct values.

And when do you do this validation?


Well for e.g. where I want only text to be allowed (for e.g. Name field) if I write numbers it won't notice the error while if I don't write anything error is detected... I hope I formulated my problem correctly, just saying Mandatory is already set on True. 

Solution

Dude, your field being as text, it will accept numbers, characters, because text gets many things.
So in the Extended Propertis of the input, you can put an onkeydown, and a javascript: 


 "document.getElementById('"+InputProduto.Id+"').onkeypress = function(e) {
         var chr = String.fromCharCode(e.which);
         if ('1234567890'.indexOf(chr) >= 0)
           return false;
       };"

Where InputProduto is the name of your input.

Solution

davit kamushadze wrote:

Hello guys! 

Validation of inputs shows error only in case if it's empty, not in case if the type is invalid. can anyone help?

Hi Davit,

can you please try below component in outsystems forge.

https://www.outsystems.com/forge/component-overview/3308/restrict-chars-sample

Thanks,

AV


Hi

You can download this component https://www.outsystems.com/forge/component-overview/1002/restrictchars
and it has a webblock with the name RestrictChars, just put it next to your input, pass the name of your input to it, and it will also ask you, an id type of your input, in your case, just pass letters.
Look at the example:

Component:


Static Entity:


Input whit webblock:


WebBlock setup:


I hope to help.