I have a form that, using jQuery, will create code that asks for Admin Approval in certain instances. The instance I'm specifically working on right now asks for Admin Approval if a lower level user tries to raise their own level (this can be allowed IF someone higher than them allows it).
For several other inputs
on the page, I have the following code running to accept a stroke on the "Enter" key as a substitute for pushing the "Submit" button.
$('input[kind="pw1"]').keyup(function (key) {
var enterKey = key.which;
if (enterKey == 13) {
$("#submit2").trigger("click");
}
});
This works for literally every single input I've done so far, except the one that I'm using for a user to input a higher level password. It's exactly the same as the code above, except it's input[kind="adPw"]
to specify the Admin Approval input. Instead of triggering a click on the submit button, it tries to reload the page.
I've tried out a lot of different fixes thus far:
- Calling by ID
- Unbinding other clicks on all
inputs
- Unbinding other clicks on all
.button
- Unbinding other clicks on just this
input
- Checked all code for anything linking this
input
to a reload - Checked all code for anything linking any
input
to a reload
I did some research as well, but I'm not finding anything that's quite on target for the issue that I'm having. I'm also not receiving any errors or warnings in the console, and I'm 99% certain that all of my tags are properly closed.
I'm linking to a JSFiddle below so that you can also experience this crazy thing. I've re-coded it to speed up your time there. It will create two users for you: and admin, and a regular user, then it will reload the page. When it does, follow these steps:
- Log in as the regular user (U: "tester", P: "password")
- The "Enter key" code is at work here on both the Username
input
and thepassword
input, and it definitely works here!
- The "Enter key" code is at work here on both the Username
- Click on "Manage Users"
- Change tester's level to "Level 2"
- Click on "Save Changes"
This is the Admin Approval box. If you click the Submit button, it will give the alert
"sub2", indicating a click on the button. If you hit "Enter" while in the input
box, it should do the same thing, but instead it tries to reload the page.