hi, i want to show some extra fields in case of datebirth value tells the user is underaged.
i already have the checkBirth function, but how can i define onChange javascript action on that field?
i already have the checkBirth function, but how can i define onChange javascript action on that field?
Hi alfredopacino,
Give the checkbox an ID like datebirth then add this to a Load JS action in your form.
You could also use the onKeyup event but then your checkBirth function would need to check to see if the date was complete.
You can also set up a datepicker that will only accept dates more than, say, 16 years in the past - but this can give you other validation problems.
Bob
Give the checkbox an ID like datebirth then add this to a Load JS action in your form.
window.addEvent('domready', function() {
$('datebirth').addEvent('blur', checkBirth);
});
You could also use the onKeyup event but then your checkBirth function would need to check to see if the date was complete.
You can also set up a datepicker that will only accept dates more than, say, 16 years in the past - but this can give you other validation problems.
Bob
here is my Custom code action who doesnt work
the onchange action seems do nothing
this is the entire form field
should i add #datebirth_clone_id somewhere to js function?
the onchange action seems do nothing
<?php
$giorno_adesso = date('d');
$mese_adesso = date('m');
$anno_adesso = date('Y');
?>
<script language="javascript">
window.addEvent('domready', function() {
$('datebirth').addEvent('change', function() {
var date=document.getElementById("datebirth").value;
alert("data: "+date);
var anno=parseInt(date.substring(0,4),10);
var mese=parseInt(date.substring(5,7),10);
var giorno=parseInt(date.substring(8),10);
alert ("giorno "+giorno+" mese "+mese+" anno "+anno)
if((<?php echo $anno_adesso ?> - anno) > 18 ) { alert ("sei maggiorenne"); }
else if ((<?php echo $anno_adesso ?> - anno) < 18 ) { alert ("sei minorenne"); }
else if(((<?php echo $anno_adesso ?> - anno) == 18) && (<?php echo $mese_adesso ?> >= mese) && (<?php echo $giorno_adesso ?> >= giorno))
{ alert ("sei maggiorenne"); }
else { alert ("sei ancora minorenne"); }
});
});
</script>
this is the entire form field
<label for="datebirth">Data di nascita</label><input style="display: none;" id="datebirth" maxlength="150" size="16" class="validate['required'] cf_date_picker" title="" name="datebirth" value="2007-05-25" type="text"><input id="datebirth_clone_id" style="display: inline-block;" maxlength="150" size="16" class="validate['required'] cf_date_picker" title="" value="2007-05-25" type="text">
<div class="clear"></div><div id="error-message-datebirth"></div>
should i add #datebirth_clone_id somewhere to js function?
Hi alfredopacino,
Please post a link to the form so I can take a quick look.
Bob
Please post a link to the form so I can take a quick look.
Bob
im still in local..
the field has id #datebirth but chronoform print #datebirth_clone_id for the actually visible input field, i tryed to replace datebirth for datebirth_clone_id in the function but still doesnt work.
the field has id #datebirth but chronoform print #datebirth_clone_id for the actually visible input field, i tryed to replace datebirth for datebirth_clone_id in the function but still doesnt work.
Hi alfredacino,
That used to happen with the old Monkeyphysics datepicker. Please try using the MooTools datepicker - you can switch over on the form General tab.
Bob
That used to happen with the old Monkeyphysics datepicker. Please try using the MooTools datepicker - you can switch over on the form General tab.
Bob
:D i solved thanks.
a little question yet: the datepicker tells the birthdate so it can't be tomorrow 🙂 , there's any change to disable future dates?
a little question yet: the datepicker tells the birthdate so it can't be tomorrow 🙂 , there's any change to disable future dates?
This topic is locked and no more replies can be posted.