cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rohitsekar1996
Helper I
Helper I

Auto (Slash) add in input field

Hi All,

I have been trying to create a user form. I have a field named "Valid to" were user will be typing date in (mm/dd/yyy) format and I have some other conditions so I cant use Date picker . My query is when user typing date I need to auto populate slash(/) between the mm/dd/yyy is it possible to add slash between intervals so user don't have to add slash manually.

1 ACCEPTED SOLUTION

Accepted Solutions

I like where @eka24 is going with the IsMatch Regex, and I think we can extend that to actually insert the slashes when the format matches one of two correct formats.

 

So keep the Text colour setting @eka24 suggested, this will notify the user when the format they've entered is incorrect, but only if it matches ##-##-####, so we can extend that to include ######## and ##/##/#### as well:

If(
   IsMatch( Self.Text, "\d{2}-\d{2}-\d{4}" )
   ||
   IsMatch( Self.Text, "\d{2}\d{2}\d{4}"
   ||
   IsMatch( Self.Text, "\d{2}\/\d{2}\/\d{4}" )
   ,White,Red
)

 

Then in your control's Default, set it to DateValidated

(a variable we will shortly set via the OnChange)

 

in your control's OnChange, have it do the following:

If(
   IsMatch(Self.Text), "\d{2}-\d{2}-\d{4}",
   Set(DateValidated,
       Left(Self.Text,2) & "/"
      & Mid(Self.Text,4,2) & "/"
      & Mid(Self.Text,7,4)
   ),
   IsMatch(Self.Text), "\d{2}\d{2}\d{4}",
   Set(DateValidated,
       Left(Self.Text,2) & "/"
      & Mid(Self.Text,3,2) & "/"
      & Mid(Self.Text,5,4)
   )
)

 

What the above does is adds in the text slashes to either 01032020 or to 01-03-2020 if it matches those patterns 🙂

 

Hope this helps!

 

Cheers,

Sancho

@iAm_ManCat


Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


View solution in original post

2 REPLIES 2
eka24
Super User III
Super User III

What about letting User select a DatePicker and the results or what has been selected Automatically populate the Textbox?

 

In the Default of the Textbox;

DatePicker1.SelectedDate

Format the DatePicker to "mm/dd/yyyy"

 

If that's not ok try validating the Textbox using the Fill color;

If(IsMatch( "11/11/1111", "\d{2}-\d{2}-\d{4}" ),White,Red)

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

I like where @eka24 is going with the IsMatch Regex, and I think we can extend that to actually insert the slashes when the format matches one of two correct formats.

 

So keep the Text colour setting @eka24 suggested, this will notify the user when the format they've entered is incorrect, but only if it matches ##-##-####, so we can extend that to include ######## and ##/##/#### as well:

If(
   IsMatch( Self.Text, "\d{2}-\d{2}-\d{4}" )
   ||
   IsMatch( Self.Text, "\d{2}\d{2}\d{4}"
   ||
   IsMatch( Self.Text, "\d{2}\/\d{2}\/\d{4}" )
   ,White,Red
)

 

Then in your control's Default, set it to DateValidated

(a variable we will shortly set via the OnChange)

 

in your control's OnChange, have it do the following:

If(
   IsMatch(Self.Text), "\d{2}-\d{2}-\d{4}",
   Set(DateValidated,
       Left(Self.Text,2) & "/"
      & Mid(Self.Text,4,2) & "/"
      & Mid(Self.Text,7,4)
   ),
   IsMatch(Self.Text), "\d{2}\d{2}\d{4}",
   Set(DateValidated,
       Left(Self.Text,2) & "/"
      & Mid(Self.Text,3,2) & "/"
      & Mid(Self.Text,5,4)
   )
)

 

What the above does is adds in the text slashes to either 01032020 or to 01-03-2020 if it matches those patterns 🙂

 

Hope this helps!

 

Cheers,

Sancho

@iAm_ManCat


Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


View solution in original post

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

Top Solution Authors
Top Kudoed Authors
Users online (63,661)