Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

SSN Validation Help

Avatar

Avatar
Validate 1
Level 4
Ryan_Lunka
Level 4

Likes

11 likes

Total Posts

143 posts

Correct Reply

11 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 4
Ryan_Lunka
Level 4

Likes

11 likes

Total Posts

143 posts

Correct Reply

11 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
Ryan_Lunka
Level 4

14-07-2008

I am creating a form that is to validate if the user has entered a valid SSN. I selected the correct validation pattern and checked "Error" to show the error message, but I would like to immediately reset the focus to the SSN field if it is invalid. I understand logically how to do this but I can't figure out the actual script for it.

_________________________



Taxpayer.#subform[0].Section1.TaxpayerSSN.fldTaxpayerSSN1::validate - (JavaScript, client)



if (!!!HERE IS WHAT I CANT FIGURE OUT!!!)

{

xfa.host.setFocus(this)

}



_________________________



Any help?

Replies

Avatar

Avatar
Validate 1
Level 4
Ryan_Lunka
Level 4

Likes

11 likes

Total Posts

143 posts

Correct Reply

11 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 4
Ryan_Lunka
Level 4

Likes

11 likes

Total Posts

143 posts

Correct Reply

11 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
Ryan_Lunka
Level 4

14-07-2008

Well, nevermind. I guess I figured out a solution. Just for reference, here is what I came up with. Most notable is the fact that I moved to the "Exit" event.



Taxpayer.#subform[0].Section1.TaxpayerSSN.fldTaxpayerSSN1::exit - (JavaScript, client)



var re = /^([0-6]\d{2}|7[0-6]\d|77[0-2])([ \-]?)(\d{2})\2(\d{4})$/;

if (!re.test(this.rawValue) && this.rawValue != null)

{

xfa.host.messageBox("Please enter a valid Social Security Number");

xfa.host.setFocus(this);

}

else

{

var temp = value;

if (value.indexOf("-") != -1)

{

temp = (value.split("-")).join("");

}

if (value.indexOf(" ") != -1)

{

temp = (value.split(" ")).join("");

}

if (temp.substring(0, 3) == "000")

{

xfa.host.messageBox("Please enter a valid Social Security Number");

xfa.host.setFocus(this);

}

if (temp.substring(3, 5) == "00")

{

xfa.host.messageBox("Please enter a valid Social Security Number");

xfa.host.setFocus(this);

}

if (temp.substring(5, 9) == "0000")

{

xfa.host.messageBox("Please enter a valid Social Security Number");

xfa.host.setFocus(this);

}

}



I borrowed and modified this code from this location:

http://www.breakingpar.com/bkp/home.nsf/0/87256B280015193F87256F6A0072B54C