Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JavaScript to format SSN

743607Jun 5 2012 — edited Jun 5 2012
Hello,

Im using Apex 4.1, Oracle 11g.

I have a simple page, and the requirement is to automatically format a SSN field to include dashes (-) should the customer only enter in all numbers.

I have written a javascript function to handle this, but no matter how I alter the substrings, the output is not correct.

Using the example below (with an onblur call on the element attribute) for an input of 123456789 returns: 123-3-5


<script type="text/javascript">

function FormatSSN() {

var SNN;
SSN = document.getElementById("P9_SSN").value ;

if (SSN.length == 9) {
document.getElementById("P9_SSN").value = SSN.substring(0,3) + "- " + SSN.substring(3,2) + "-" + SSN.substring(5,4);

}
}
</script>

Ive modified the values in the substring many times but none of the ouput makes any sense.

Can someone please advise.

Thank you,
Laura

Edited by: LauraK on Jun 5, 2012 10:06 AM
This post has been answered by fac586 on Jun 5 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 3 2012
Added on Jun 5 2012
4 comments
2,673 views