Вход в виджет плагина не допускает пробелов

Я разрабатываю плагин для клиента, который позволяет хранить записи о бронировании в своем отеле, и у него есть виджет, который позволяет клиентам делать оговорки. Однако по какой-либо причине одно из полей в виджетах <input type="text" name="res_name" id="res_name" /> не допускает пробелов, и я честно застрял здесь.

Это код, который отображает виджет:

 <?php defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); /** * Adds Res_Widget widget. */ class Res_Widget extends WP_Widget { /** * Register widget with WordPress. */ function __construct() { parent::__construct( 'reservations_widget', // Base ID __( 'Reservations', 'text_domain' ), // Name array( 'description' => __( 'A Reservation making widget', 'text_domain' ), ) // Args ); } /** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ public function widget( $args, $instance ) { echo $args['before_widget']; if ( ! empty( $instance['title'] ) ) { echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ). $args['after_title']; } $html = '<div class="reservation_module_widget">'; $html .= '<h2>' . __('Reservations', 'text_domain') . '</h2>'; $html .= '<form name="reservation_widget" method="post" id="res_form" action="">'; $html .= '<div class="res_form-row">'; $html .= '<div class="res_form-group">'; $html .= '<label for="res_arrival">'; $html .= __('Arrival', 'text_domain'); $html .= '</label>'; $html .= '<input name="arrival" type="date" id="res_arrival"/>'; $html .= '</div>'; $html .= '<div class="res_form-group">'; $html .= '<label for="res_checkout">'; $html .= __('Checkout', 'text_domain'); $html .= '</label>'; $html .= '<input name="checkout" type="date" id="res_checkout" disabled />'; $html .= '</div>'; $html .= '</div>'; $html .= '<div class="res_form-row" id="room_data"></div>'; $html .= '<div class="res_form-row">'; $html .= '<div class="res_form-group hidden" data-hidden="true">'; $html .= '<label for="res_name">'; $html .= __('Name', 'text_domain'); $html .= '</label>'; $html .= '<input name="res_name" id="res_name" type="text" />'; $html .= '</div>'; $html .= '<div class="res_form-group hidden" data-hidden="true">'; $html .= '<label for="res_email">'; $html .= __('Email', 'text_domain'); $html .= '</label>'; $html .= '<input name="email" id="res_email" type="email" />'; $html .= '</div>'; $html .= '</div>'; $html .= '<div class="res_form-row"><div class="res_form-group">'; $html .= '<input type="submit" value="'. __('Confirm Reservation', 'text_domain') .'"/>'; $html .= '</div></div>'; $html .= '<div id="form_errors"></div>'; $html .= '</form>'; $html .= '</div>'; echo $html; echo $args['after_widget']; } /** * Back-end widget form. * * @see WP_Widget::form() * * @param array $instance Previously saved values from database. */ public function form( $instance ) { $title = ! empty( $instance['title'] ) ? $instance['title'] : __( 'New title', 'text_domain' ); ?> <p> <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>"> </p> <?php } /** * Sanitize widget form values as they are saved. * * @see WP_Widget::update() * * @param array $new_instance Values just sent to be saved. * @param array $old_instance Previously saved values from database. * * @return array Updated safe values to be saved. */ public function update( $new_instance, $old_instance ) { $instance = array(); $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : ''; return $instance; } } function register_res_widget() { register_widget("Res_Widget"); } add_action( 'widgets_init', 'register_res_widget' ); /**/ 

Представленная форма:

 <div class="reservation_module_widget"> <h2>Reservations</h2> <form name="reservation_widget" method="post" id="res_form" action=""> <div class="res_form-row"> <div class="res_form-group"> <label for="res_arrival">Arrival</label> <input name="arrival" type="date" id="res_arrival"> </div> <div class="res_form-group"> <label for="res_checkout">Checkout</label> <input name="checkout" type="date" id="res_checkout" disabled=""> </div> </div> <div class="res_form-row" id="room_data"></div> <div class="res_form-row"> <div class="res_form-group hidden" data-hidden="true"> <label for="res_name">Name</label> <input name="res_name" id="res_name" type="text"> </div> <div class="res_form-group hidden" data-hidden="true"> <label for="res_email">Email</label> <input name="email" id="res_email" type="email"> </div> </div> <div class="res_form-row"> <div class="res_form-group"> <input type="submit" value="Confirm Reservation"> </div> </div> <div id="form_errors"></div> </form> </div> 

Это код js, который обрабатывает форму

 $(document).on('change', 'input[name="checkout"]', function(){ if (this.value!='' && this.value > $('input[name="arrival"]').val()){ var arrival = $('input[name="arrival"]').val(), checkout = this.value; $.ajax({ type: 'get', url: ajaxfilter.ajaxurl, data: {action:'reservationManagement', arrival:arrival, checkout:checkout, type:'client'}, success: function(result){ try{ var rooms = JSON.parse(result); var select = ''; var options = ''; rooms.forEach(function(room){ options += '<option value="' + room.id + '">' + room.name + '</option>'; }); select = '<div class="res_form-group">'; select += '<label for="res_room">Room</label>'; select += '<select name="res_room" id="res_room">'; select += options; select += '</select>'; select += '</div>'; if(rooms.length>0){ if($('#res_room').length > 0){ $('#res_room').html(options); } else{ $('#room_data').append(select); $('.res_form-group[data-hidden]').removeClass('hidden'); } } } catch(e){ $('#room_data').html(''); $('.res_form-group[data-hidden]').addClass('hidden'); $('#form_errors').html('<p>'+result+'</p>'); setTimeout(function(){ $('#form_errors').html(''); }, 4000); } } }); } else{ console.log('invalid'); } }); 

Solutions Collecting From Web of "Вход в виджет плагина не допускает пробелов"