182
Views
18
Comments
Solved
How to validate space/blank in an input.
Question
Application Type
Reactive

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.

2023-06-06 10-13-52
Rishabh Chawda
Solution

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.

Regards,

Rishabh.


UserImage.jpg
Joe Ng

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.


Regards,

Joe.

2024-05-08 06-29-37
Prince Aadil Khan Panwar
Solution

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

2024-05-08 06-29-37
Prince Aadil Khan Panwar

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.

Prince

UserImage.jpg
Joe Ng

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.


Regards,

Joe.

2024-05-08 06-29-37
Prince Aadil Khan Panwar
2021-01-04 08-13-48
Toto
 
MVP

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.

UserImage.jpg
Joe Ng

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.


Regards,

Joe.

2021-08-12 05-19-40
Shubham Janbandhu

Hi Joe Ng,

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.

Regards,

Shubham

UserImage.jpg
Joe Ng

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.


Regards,

Joe Ng.

2023-09-15 13-34-43
Sushant Sharma

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

SpaceInString.oap
UserImage.jpg
Joe Ng

Hi Sushant Sharma, 


I found a solution few days ago and I forget to mark this question solved,


Thank you for your response, Hope your solution helps others who seen this post.


Have a great day ahead.


Regards,

Joe.

2025-02-10 17-24-13
Arun Rajput

Hi Joe,

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

UserImage.jpg
Joe Ng

Hi Arun Rajput, 


I found a solution few days ago and I forget to mark this question solved,


Thank you for your response, Hope your solution helps others who seen this post.


Have a great day ahead.


Regards,

Joe.

2023-11-22 10-51-50
Jozy Sohail

Hi Joe,

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

Thanks

2025-02-10 17-24-13
Arun Rajput

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.

2023-11-22 10-51-50
Jozy Sohail

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.

UserImage.jpg
Joe Ng


Hi Jozy Sohail, 


I found a solution few days ago and I forget to mark this question solved,


Thank you for your response, Hope your solution helps others who seen this post.


Have a great day ahead.


Regards,

Joe.

2023-06-06 10-13-52
Rishabh Chawda
Solution

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.

Regards,

Rishabh.


UserImage.jpg
Joe Ng

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.


Regards,

Joe.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.