javascript - How to validate birthdate input box with jQuery -


how can validate following input box creating function without using jquery plugins?

this doing till , found out function parsedate used plugin not work me.

.js file code:

function isbirthdate(valor){  if (parsedate(valor, "dd-mm-yyyy"))     return true;  else     return false;    } 

.php file jquery code:

    if (isbirthdate($('#fecha_nacimiento').val()) == true){         errormasg('#fecha_nacimiento',"<?php echo     jtext::_('com_cstudomus_numeric_texto_formato');?>");         return false;     } 

.php file input box code:

<input name="fecha_nacimiento" id="fecha_nacimiento" type="text" placeholder="<?php echo jtext::_('com_cstudomus_date_format'); ?>" value="<?php echo jhtml::date($userdata->fecha_nacimiento, 'd-m-y'); ?>" tabindex="6"> 

im importing .js file correctly there no issue there.

i have found solution doing following:

.js file code:

function isvalidatedate(valor){     var regexpre = new regexp(/\b\d{1,2}[\/-]\d{1,2}[\/-]\d{4}\b/);         if (valor.match(regexpre))             return true;         else             return false; } 

.php file jquery code:

if (isvalidatedate($('#fecha_nacimiento').val()) == false){     errormasg('#fecha_nacimiento',"<?php echo jtext::_('com_cstudomus_fecha_nac');?>");     return false; } 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -