how to allow user to enter only numbers in text box

how to allow user to enter only numbers in text box

  

hi friends,

                I'am having a input box which is of type text but i want to allow user to type only numbers how we can do it.since my text box contain prefix code(+91) i'am keeping the text box type as text

Hi Karthik,

You can use the regular expression for that. In outsystem, under Under TEXT extension you will find one action i.e. Regex Search, with help of that you can validate any text or string pattern. Hope this will help. i will also try to upload the sample oml for you.

Regards,

Manish Jawla

Hi Karthik,

Please find the sample oml attached.

It will validate this pattern- +91-9039292571 and 9039292571 both are valid, other than this will be invalid.

Hope this will help. :)

Regards,

Manish Jawla.


Manish Jawla wrote:

Hi Karthik,

Please find the sample oml attached.

It will validate this pattern- +91-9039292571 and 9039292571 both are valid, other than this will be invalid.

Hope this will help. :)

Regards,

Manish Jawla.


hi manish,

                     can u explain the below syntax and input parameters in regex_search server action

SyntaxEditor Code Snippet
"^((\+)?(\d{2}[-]))?(\d{10}){1}?$"





Solution

Hi Karthik,

Since i was a .net developer in the past, so i am used to these regular expression. If you want to learn more about them, you can google it you will find plenty of tutorial and meaning of each symbols used in it. you can also create your own regular expression its simple.

If you find the solution helpful and correct please mark it as solution and like it :)

Regards, 

Manish Jawla

Solution

Manish Jawla wrote:

Hi Karthik,

Since i was a .net developer in the past, so i am used to these regular expression. If you want to learn more about them, you can google it you will find plenty of tutorial and meaning of each symbols used in it. you can also create your own regular expression its simple.

If you find the solution helpful and correct please mark it as solution and like it :)

Regards, 

Manish Jawla


hi manish,

                     with mask number also we can do but i have no idea of how to implement it



Hi Karthik,

Please let me know the input and desired output string, i will try by best to help u out. :)

Regards,

Manish Jawla

Manish Jawla wrote:

Hi Karthik,

Please let me know the input and desired output string, i will try by best to help u out. :)

Regards,

Manish Jawla



hi Manish,

                 I have attached my module for your reference.In this module after user enters the mobileno and after choosing country code from module it get prefixed to the mobile no.suppose when user select another code it should replace the excisting code instead of appending the code again and when user enter alphabet it should notify them please enter the number.how we can do it

                     For checking the entered value is alphabet is there any condition like var<>'a' to 'z'

                 





Hi Karthik,

i have seen your module, now below are the solutions:

1. for checking whether the user has not entered the  number only, or string contain alphabet or any other special character. you can use this simple regex "^[0-9]*$" and copy the code from my oml. it will validate it.

2. for appending the desired country code in the phone number:

a) onchange action you need to simply fetch the selected country code which is simple u have already binded the variable to it, use that variable in aggregate to fetch the selected country code.

b) simple use the assignment operator to append that selected country to your entered mobile no. and reassign it to the text box refresh it. its done :). hope this help. don't forgot to like.

Regards,

Manish Jawla