The form below has a date field, a time field, and a numerical field.

Using JavaScript, I've made a change in the time field trigger code to check if the time is less than 24 hours in the future. This can be used to add a premium to last-minute bookings, disable submission, whatever you need to have happen.

In the current example, a message is shown and the value in the numerical field is changed if the date/time selected is less than 24 hours in the future.

24 Hour Limit Test

The code to accomplish this is below:

    // Set variable to current date and time
    const now = new Date();
    let stamp = now.getTime();
    let tomorrow = stamp + (86400000);
        let date_array = $('#field_date').val().split('/');
        let time_array = $('#field_time').val().split(':');
        const time_slot  = new Date(date_array[2],(date_array[0] - 1),date_array[1],time_array[0],time_array[1]);
        let time_stamp = time_slot.getTime();
        if( time_stamp < tomorrow ) {
            $('#field_notif').html('Your selected time is less than 24 hours in the future. Last-minute bookings are subject to a surcharge.');
        } else {
            $('#field_notif').html('Your selected time provides adequate notice, so no surcharge will be levied.');

This is useful when displaying data side-by-side in situations where you don't want to use a table, and the height of individual elements may vary.

Also good for situations where you want your elements to lay out responsively in neat little rows without being forced to set an absolute height or min-height, and without using a "masonry" approach.

It also makes sense to bind this to the window re-size event or other events on occasion, but I'll leave that to you.

[vc_row][vc_column][vc_column_text]I need to do this all the time, but just infrequently enough that I have to figure it out all over again every time. No more. Now I have a handy-dandy inter-web-net-highway marker! 😛

All you need to do is replace the elements mentioned in the comments with references to your own, and you're off to the races!


Put this in your functions.php or a plugin:

function  bsn_search_users() {
	$user = get_user_by( 'email', $_REQUEST['user_email'] );
	if(false === $user) { // user doesn't exist
		// do something like:
		echo 'email not found'; // replace 'yourstatusmessageclass' with some class you define to hold the message
	} else {
		// show the form
		echo ""; // replace 'form_wrapper_div' with the id of a div you place the form in

Then in your page, go:

[vc_row full_width="" parallax="" parallax_image=""][vc_column width="1/1"][vc_column_text]THE PROBLEM: Scripts can often impair loading of pages. Browsers choke, users get frustrated with waiting, customers go elsewhere.

THE CAUSE everybody uses the jQuery(document).ready(); event to load their scripts. Everything is trying to load all at once and bogging down the processor and working memory on the client machine.

THE FIX: don't use jQuery(document).ready() to load everything.
Bind your scripts to user actions like mousemove, mouseenter, click, etc.

This way your scripts only load when they're needed and the page loads quickly, without hanging browsers and annoying users.

That's it! Easy peasy. NEVER forget![/vc_column_text][/vc_column][/vc_row]

    // change this bit to whatever you need to
    if( jQuery(this).val() == 'Whatever' ) {
        jQuery('#second_field').val('Saved Vaue');

"What's the point" you ask?

The point is that you can't just bind willy-nilly to ajaxComplete on a page where there are multiple elements using ajax. You have two options: either filter the results like so:

jQuery( document ).ajaxComplete(function( event, xhr, settings ) {
  if ( settings.url === "ajax/test.html" ) {
    jQuery( ".log" ).text( "Triggered ajaxComplete handler. The result is " +
      xhr.responseText );

Or, as is sometimes the case, you want to reload or redirect the entire page on completion of a particular action, usually triggered by a click. You can use the method above to do it, but I find the .click method more readable if I wander back six months later and have to try to figure out what I was doing, which is often the case.

jQuery(document).ready(function() {
  jQuery('.mss-item-cell').click( function(){ 
   jQuery ( document ).ajaxComplete( function() {
      // do your stuff
	 // i.e. to reload the page after the action is complete go:
	 // location.reload(); 

A simple function to easily retrieve GET parameters by name.
for the URL:

var prodId = getParameterByName('prodId');

Sets the javascript variable "prodID" to "1234" as defined on the GET string.

 * function getParameterByName(name)
 * returns value defined in URL parameter
function getParameterByName(name) {
    name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
        results = regex.exec(;
    return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));

Subscribe To Our Newsletter

Join our mailing list to receive the latest news and updates from our team.

Email sending image

You have Successfully Subscribed!