I'm using Bootstrap and JQuery UI and i seem to have stumbled upon a problem. I styled most of my code in Bootstrap. I was trying to implement a age validation dialog-box "Validation: if a person is less then 18 years of age do something...". I managed to implement that age-checking validation with JQuery. Next, I wanted to make the input-field look like bootstraps input fields, because all of my input-fields in my main form look like the bootstraps input-field. How can i accomplish this?
$(document).ready(function () {
$("#age").datepicker({
onSelect: function(value, ui) {
var current = new Date().getTime(),
dateSelect = new Date(value).getTime();
age = current - dateSelect;
ageGet = Math.floor(age / 1000 / 60 / 60 / 24 / 365.25); // age / ms / sec / min / hour / days in a year
if(ageGet < 18){
less_than_18(ageGet);
}
},
yearRange: '1900:+0d',//base year:current year
changeMonth: true,
changeYear: true,
defaultDate: '-18yr',
}).attr("readonly", "readonly"); //prevent manual changes
function less_than_18(theAge){
$( function() {
$('<div></div>').dialog({
modal: true,
title: "Age Check?",
open: function () {
var markup = 'Applicant is not 18 years old. Do you wish to continue?';
$(this).html(markup);
},
buttons: {
'Confirm': function() {
$(this).dialog('close');
},
'Change': function() {
$('#age').val('');
$(this).dialog('close');
}
}
});
} );
}
});
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<div class="container">
<div class="form-group">
<input type="text" class="form-control" placeholder="Select your age" id="age">
</div>
</div>