user1608231
user1608231

Reputation: 65

javascript text field to popup

asked the original question here: Javascript - text field submits to a popup window

Mash was kind enough to help and answer.

I'm having a strange issue where on the Home page the code is NOT working - goes into the alert each time. but on other pages - it seems to be working properly.

to test use the code: 120663A

Scroll down and enter the lot number above

Any suggestions/help would be very welcome?

thanks joey

Upvotes: 2

Views: 275

Answers (2)

swemon
swemon

Reputation: 5946

Although you keep text-transform: uppercase in both page. when you type 120663a, $('input[type=text]').val() only show 120663a.

That's why if ($('input[type=text]').val() == "120663a") { in http://freshomega.com/w/tester works and

if ($('input[type=text]').val() == "120663A") { in http://freshomega.com/w/ does not work. I hope this will help.

You can test 120663A in both page, the result will be reverse.

To solve this, I will do the input text to change upper case in both pages for consistency using toUpperCase() function or change both to lower case.

For example,

if ($('input[type=text]').val().toUpperCase() == "120663A") {
    window.open("http://freshomega.com/w/files/120663A.pdf");

I hope this would help.

Upvotes: 1

aug
aug

Reputation: 11714

Actually both of your websites work but you are not handling capitalization. In http://freshomega.com/w/ your code says:

if ($('input[type=text]').val() == "120663A") {

and then in http://freshomega.com/w/tester your code says:

if ($('input[type=text]').val() == "120663a") {

See the difference? If you straight up type "120663a" into the first one, it's not going to work because it is looking for the capital A. Maybe you can make it disregard case altogether with a .toLowerCase() or .toUpperCase()? Hope this helps.

Upvotes: 3

Related Questions