0

I need your help,

Is there a way to code a javascript function that would regex and test a string or using any other means to check if a date string already has the two forward slashes in it? ie. dd/mm/yyyy

regex('04/07/2014') { return true }

Thanks in advance for all your help?

Jason Kelly
  • 2,539
  • 10
  • 43
  • 80

3 Answers3

1

You can use a regex test:

/\/.*\//.test("04/07/2014")
ikegami
  • 367,544
  • 15
  • 269
  • 518
0

You can use this regex:

/([^/]*\/){2}/

to check if input has at least 2 forward slashes.

anubhava
  • 761,203
  • 64
  • 569
  • 643
0

use /\/.*\//.test( str ) it returns true if str has two forward slashes in it.

Vlas Bashynskyi
  • 1,886
  • 2
  • 16
  • 25