Good day,
I would like to ask how to validate space or blank like form validation, which means when the input contain space/blank, the save function won't success. E.g. The Project code contain space, how to make it validate as the Project name?
Hope I explain clearly on my doubt, thanks in advance.
Regards,
Joe.
Hi @Joe Ng
There are two ways to validate whether an input contains a space or is blank:
1. You can use the index function to check if there is space in your text.
2. To validate blank input, you can make use of regular expressions (regex) which have an inbuilt function for searching.
I hope it will be helpful to you.
Rishabh.
Hi Rishabh Chawda,
I found a solution few days ago and I forget to mark this question solved, the solution I found is actually same as the second solution you suggested.
Thank you for your response, Hope your solution helps others who seen this post.
Have a great day ahead.
Hi Joe Ng,
i would suggest you use regex for validating input.
- you can use inbuilt function regex search
or
you can try with javascript as well
thanks
Prince
sorry i thought you have been asking for string should not contain blank values. as @Toto suggest you should do it and don't forget to assign those values, if true then this
if text is valid then this
thanks.
Hi Prince,
Thanks for your response, I will mark your reply as solution if it can solve my doubt.
Thanks again and have a great day ahead.
any time. Joe Ng
Hi Joe,
If you using bootstrap from Outsystems (not the javascript), there should already validation for not empty. you need to modify that by also doing trim, so space will be ignored.
Hi Toto,
Thanks for your reply.
I'm not using bootstrap in this reactive app, your suggestion is a good reference for me on my study. Thank you and have a good day ahead.
Sharing one more method which will prevent save function.
Check space by Trim method, once you will get empty space you can make that input invalid.
Shubham
Hi Shubham Janbandhu,
Thanks for your response, but it is not work in my case, I will make another try after this.
Have a good day ahead.
Joe Ng.
Hello Joe,Please find the Sample attached for your Space Validation.It will only Allow String and If You will Input any space in between it will restrict.
Thanks
Hi Sushant Sharma,
I found a solution few days ago and I forget to mark this question solved,
If above solutions not worked then I have one more solution.
On the save button logic first check the length of text and hold it on one local variable then trim the same text check the length of trimmed text and hold it on another local variable.
Now compare both the length if length are different that means there is space with text and according to this you can show validation message.
Thanks,
Arun
Hi Arun Rajput,
You can use the index function to check if there is space in your text like this.
If this condition returns value more then -1(i.e. TRUE) then it means your text in having space.
Hope it helps
Hi Jozy,
Index will be failed if there is space between the words
For Ex- "Project Code" index will return greater than -1 in this case also.
Hi Arun,
Yes you are correct in this case it will fail, but I assume that is what Joe needs as his original comment said "when the input contain space/blank, the save function won't success".
i think he needs to restrict the save function even if there is space in between.
Hi Jozy Sohail,