Okay
  Public Ticket #872628
datatables
Closed

Comments

  •  2
    anuraag started the conversation

    need help, can we have a constraint to add maximum 10 digits in one-line edit string from the front end

  •  1,667
    Miloš replied

    Hi anuraag,
    Thank you for your purchase.

    Unfortunately this is not possible with built-in functionalities, and it can be done with little customization. I have wrote little jQuery snippet that you can add on Custom wpDataTables JS field on wpDataTables settings page. With this jQuery snippet If length of one-line edit input field is 10 or more characters OK and Apply button will be disabled. This maybe is not the best solution, because if somebody know to Inspect element on your page and remove disabled attribute of button he can add data to your table. The better solution will be if you can do that on back-end. For this jQuery snippet you have just to change names of your input fields.

    jQuery( window ).load(function() {
        jQuery( "#table_1_name_of_input_field" ).keyup(function() {
            var num = jQuery('#table_1_name_of_input_field').val()
            if(num.length >= 10){
                 jQuery('#table_1_apply_edit_dialog').attr( "disabled", "disabled" );
                 jQuery('#table_1_ok_edit_dialog').attr( "disabled", "disabled" );
            } else {
                jQuery('#table_1_apply_edit_dialog').removeAttr( "disabled" );
                jQuery('#table_1_ok_edit_dialog').removeAttr( "disabled" );
            }
        })
    });
    

    If you are interested in back-end customization we can offer you our paid customization service.


    Kind Regards, 

    Miloš Jovanović
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables