Expand my Community achievements bar.

SOLVED

AEM Forms DOB or SSN auto append / or - when user enters the value in the form fields

Avatar

Level 2

Hi Team,

How to append / or - when user enters the value in aem form fields. For DOB it should append / like 12/12/1990 and for SSN it should append - like 122-321-1234. Patterns option is validating once the focus is out from the form fields whether the value is with that particular format or not.

Is it possible to add / or - while entering the form field value using guideBridge API. If so can you please share some insights or examples. Thanks in advance.

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

You might have to intercept the field on key press event and add the pattern as required after checking the input length.

Ex:

$('#guideContainer-rootPanel-basics-basics1-guidetextbox_15663786___widget').keypress(function(){

// Your code

alert(textbox_156637861551694584667.value);

});

Replace guideContainer-rootPanel-basics-basics1-guidetextbox_15663786___widget with your element ID, you can obtain it from browser debugger. This need to be placed in code editor on initialize event.

Ref: https://api.jquery.com/keypress/

javascript events - jQuery get input value after keypress - Stack Overflow

View solution in original post

1 Reply

Avatar

Correct answer by
Employee Advisor

You might have to intercept the field on key press event and add the pattern as required after checking the input length.

Ex:

$('#guideContainer-rootPanel-basics-basics1-guidetextbox_15663786___widget').keypress(function(){

// Your code

alert(textbox_156637861551694584667.value);

});

Replace guideContainer-rootPanel-basics-basics1-guidetextbox_15663786___widget with your element ID, you can obtain it from browser debugger. This need to be placed in code editor on initialize event.

Ref: https://api.jquery.com/keypress/

javascript events - jQuery get input value after keypress - Stack Overflow