¿Puedo hacer una validación de advertencia de Datepicker y alertar a swal como este?
Hago eso y el error es que is_string no está definido.
soy nuevo en php por cierto
El comentario es una idea que traté de hacer de otra manera, lo siento, aborté eso.
forma
<div class="form-group"> <label>Birthdate</label> <div class="input-group date"> <span class="input-group-addon"><i class="fa fa-calendar"></i></span><input type="text" class="form-control datepicker_class" id="birth_date" name="birth_date" onchange="validateAge"> </div> </div>función
function validateAge(){ var birthday = new $('#birth_date').val(); // let birthday = $('#birth_date').val(); // check = explode('/',birthday); birthday = explode("/", birthday); // alert(check); if (is_string(birthday)) { birthday = strtotime(birthday); } // check // 31536000 is the number of seconds in a 365 days year. strtotime for 1 years : 31556926 if(time() - birthday < 18 * 31556926) { swal({ title: "warning", text: "your age is lower than 18", type: "warning" }); } return true; }En javascript no existe la función is_string(). Para verificar si la variable es una cadena, puede hacerlo de esta manera:
if (typeof birthday === 'string' || birthday instanceof String) //string else //not string