I have the following table User in my database

Name(Varchar) DateOfBirth(datetime) Age(int)

Name(Varchar) | DateOfBirth(datetime) | Age(int)
John          | 2014-12-20 23:59:59   | 0
Mary          | 2014-12-20 23:59:59   | 1

How can i verify throught javascript if the field DateOfBirth of the table User of the database z is of type datetime?

2 Years
Discussion Span
Last Post by jean_5


Why would you need to do this? If your database table states that DateOfBirth is a datetime field then it will be a datetime value. Are you looking to validate input data before saving it to the database?

Anyhow, I am not an expert in Javascript but I don't believe there is a built in date validator like isDate for example. But a quick search of google showed many results for creating your own javascript function. Also, there is a jQuery Validator plugin that may be do what you need (jQuery Validation Plugin).

Another option (not recommended) would be to use regular expressions to ensure that the input pattern is correct (BUT this would not be a true test as it would not handle leap years).


I saw this jQuery Validation Plugin. But it does not work for sql server. But thanks for the answer. Helped me a lot

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.