Jump to content

Java To Remove Hyphen In Login Page

Recommended Posts

I have my login page deployed which is working fine. the User ID is a text field that is a 9 digit number, often seen by the user as XX-XXXXXXX. In the input for the login screen, if someone enters the hyphen, I'd like to add script to remove it so it happens in the background.


This is what I added so far that is not working:


function nophyphen()
var a = document.getElementById("xip_EIN").value;
a = a.replace(/-/g, "");
Link to comment
Share on other sites

Hello wgalliance,


HTML element "form" doesn't have "onchange" event. Also after change variable "a" you didn't set it back to "value" property of input element. 


Please add this script to footer of authentication which you use.


<script type="text/javascript">
        function nophyphen() {
            var ctrl = document.getElementById("xip_UserId");
            if (ctrl) {
                ctrl.value = ctrl.value.replace(/-/g, "");

        var xip = document.getElementById("xip_UserId");
        if (xip) { xip.onchange = nophyphen };

Please pay your attention, that you need to change "xip_UserId" to correct name of your field.


You can see example below




Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...