0

Prevent html elements on inline edit Datatables

    <td class="sorting_1">
      <input type="checkbox"> 
     <i class="fa fa-cubes"></i>
     Text Field
   </td>

enter image description here

DataTable editor

   $('#dynamic-table').on('click', 'tbody td', function (e) {
    editor.inline(this);
    });

1 Answer 1

1

There are a number of ways you can do it. You can use a CSS/jQuery selector to find the first td elements in each tr and get the input element from them, and wire a jQuery blur event to them to strip disallowed characters (i.e. anything that's not alphanumeric) and / or warn/prevent user on blur, depending on how you want to handle it. You may also be able to use add a pattern attribute to input elements and provide a regex to do the same.

Sign up to request clarification or add additional context in comments.

2 Comments

$('#dynamic-table').on('click', 'tbody td', function (e) { editor.inline(this); }); This is the datatable editor how i can say this editor to skip this elements
I was suggestion to do it outside datatables. Let datatables do it's setup and then select all the relevant elements separately using CSS selectors. They'll ultimately end up being an "input" element in the DOM.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.