Skip to content

Commit

Permalink
NEW Remove spaces when copying and pasting into idprof fields
Browse files Browse the repository at this point in the history
  • Loading branch information
zephyriony committed Jun 2, 2024
1 parent ef3f007 commit 1c1fc30
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions htdocs/societe/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,25 @@

llxHeader('', $title, $help_url);

print '<script>';
print '$(document).ready(function() {';
print '$("[id^=idprof]").on("paste", function(event) {';
print 'event.preventDefault();';
print 'var clipboardData = event.originalEvent.clipboardData || window.clipboardData;';
print 'var pastedData = clipboardData.getData("Text");';
print 'var sanitizedData = pastedData.replace(/\s+/g, "");';
print 'var input = $(this);';
print 'var currentValue = input.val();';
print 'var newValue = currentValue + sanitizedData;';
print 'var maxLength = input.attr("maxlength");';
print 'if (maxLength && newValue.length > maxLength) {';
print 'newValue = newValue.substring(0, maxLength);';
print '}';
print 'input.val(newValue);';
print '});';
print '});';
print '</script>';

$countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';

$canvasdisplayaction = $action;
Expand Down

0 comments on commit 1c1fc30

Please sign in to comment.