Jump to content

jquery validate from php array


funbinod

Recommended Posts

I tried to validate if a form input is within a php array or not using jquery.

 

I tried the following

<script>$('#date').blur(function(e) {	var dt = $('#date').val();	var dtarr = <?php echo json_encode($edate); ?>;	if(!($.inArray(dt, drarr))) {		alert('NOT in range');		$('#date').focus();	}});</script>

is what I did is right or not? or I must use ajax? please suggest...

 

 

Link to comment
Share on other sites

no it doesn't work. I've set $edate as array with multiple values like ----

 

$edate= array ( 1 => '2014-07-17', 2 =>'2014-07-18', 3 =>'2014-07-19', 4 =>'2014-07-20', 5 =>'2014-07-21', 6 =>'2014-07-22', 7 =>'2014-07-23', 8 =>'2014-07-24', 9 =>'2014-07-25', 10 =>'2014-07-26', 11 =>'2014-07-27', 12 =>'2014-07-28', 13 =>'2014-07-29', 14 =>'2014-07-30', 15 =>'2014-07-31', 16 =>'2014-08-01', 17 =>'2014-08-02', 18 =>'2014-08-03', 19 =>'2014-08-04', 20 =>'2014-08-05', 21 =>'2014-08-06', 22 =>'2014-08-07', 23 =>'2014-08-08', 24 =>'2014-08-09', 25 =>'2014-08-10', 26 =>'2014-08-11', 27 =>'2014-08-12', 28 =>'2014-08-13', 29 =>'2014-08-14', 30 =>'2014-08-15', 31 =>'2014-08-16', 32 =>'2014-11-20',);

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...