Skip to content
Advertisement

jQuery non-text input validation

I have a Bootstrap table I obtained from Tutorial Republic. It goes as such:

JavaScript

When you click “+ Add New” and try to add an empty record (leaving text fields empty), you are prevented from doing so and the textbox’s border turns red.

However, when I add in a date field,

JavaScript

I am still seemingly prevented from adding a record but the border of the date box does not turn red. The same thing happens for <select> dropdown menus.

I am looking at this bit here, the line .find('input[type="text"]'):

JavaScript

but I am afraid that is the extent of my abilities as a jQuery first-timer haha!

How do you modify the code to have both text type and non-text type inputs turn red their borders?

Thank you!

Advertisement

Answer

You need to include the [type=”date”] control: .find('input[type="text"], input[type="date"])

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement