PHP + jQuery .validate issue -
ill try , make clear possible. have contact form on page , remote php file "random.php" generates 2 random numbers:
<?php $randomnum = rand(0,9); $randomnum2 = rand(0,9); echo $randomnum . ' + ' . $randomnum2; $randomnumtotal = $randomnum + $randomnum2; ?>
the parent page calls such:
$(function() { $.get( 'php/random.php', function ( data ) { $('#resetnumbers").val(data); });
and has input:
<input type="text" class="numbers" name="resetnumbers" id="resetnumbers" value="" size="6" readonly>
no problems point, php file output's 2 random numbers , displayed on page. here's problem: have second text box have add 2 numbers make validate.
<input type="text" class="numbers" name="resetmath" id="resetmath" size="6" maxlength="6" tabindex="27">
it never works. says not added correctly. here relevant part of validation rule in remote file:
resetmath: { required: true, equal: <?php echo $randomnumtotal; ?> }
since in remote file (don't want validation rules on parent page) doesn't seem getting same numbers. how unscrew mess?
resetmath: { required: true, equal: <?php echo $randomnumtotal; ?> }
doesn't seem right. should be:
resetmath: { required: true, equalto: $('#resetnumbers') }
the api here.
Comments
Post a Comment