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,333
  • 9
  • 35
  • 76

3 Answers3

1

You can use a regex test:

/\/.*\//.test("04/07/2014")
ikegami
  • 343,984
  • 15
  • 249
  • 495
0

You can use this regex:

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

to check if input has at least 2 forward slashes.

anubhava
  • 713,503
  • 59
  • 514
  • 593
0

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

Vlas Bashynskyi
  • 1,858
  • 2
  • 15
  • 25