peggasus88
Technical User
Hi,
I have a very simple form, consisitng of just a textbox for the user's ID number. I would like Submit and Reset images that have the same functionality that buttons of type="submit" or type="reset" have...
The FORM tag:
<form action="CheckLogin.asp" id="FORM" method="post" name="FORM" LANGUAGE="javascript" onsubmit="return validateID()">
The Submit and Reset images:
<P><input type="image" src="images/GoButton.gif"> <input type="image" src="images/ResetButton.gif" onclick="rst()"></P>
The validateID() function used to check if the input is an 8-digit number:
function validateID() {
ID = FORM.txtID.value;
numDigitsInID = FORM.txtID.value.length;
bPass = true;
if (ID == "" || numDigitsInID != 8 || isNaN(ID)) {
alert ("ID should be 8 digits \n Example: 10666088"
document.FORM.txtID.focus();
bPass = false;
}
return bPass;
}
The rst() function used to clear the textbox:
function rst() {
FORM.txtWWID.value = "";
document.FORM.txtWWID.focus();
}
The Submit image works AOK, although I have no idea why! The problem is with the Reset image. Some examples: If I don't enter anything into the textbox and click the Reset image, I get the alert that the ID should be 8 digits, but I'm NOT calling the validateID() function, I'm calling the rst() function! The strangest thing is that if I enter a VALID 8-digit ID, I still get the alert.
I've tried all sorts of things...I read that onclick="document.FORM.submit() submits a form so I unsuccessfully tried using onclick="document.FORM.reset()" to reset the form. I've tried using buttons of type="reset" with the image as the backgroud. But I had trouble with the sizing. If I move the Reset image outside the /FORM tag, then the correct function is called! But I can't get the buttons positioned next to each other.
I think this would just about drive anyone crazy! Newbie here (you can probably tell from my code and the issues I'm experiencing). Please help explain what is going on. =)
Peggy
I have a very simple form, consisitng of just a textbox for the user's ID number. I would like Submit and Reset images that have the same functionality that buttons of type="submit" or type="reset" have...
The FORM tag:
<form action="CheckLogin.asp" id="FORM" method="post" name="FORM" LANGUAGE="javascript" onsubmit="return validateID()">
The Submit and Reset images:
<P><input type="image" src="images/GoButton.gif"> <input type="image" src="images/ResetButton.gif" onclick="rst()"></P>
The validateID() function used to check if the input is an 8-digit number:
function validateID() {
ID = FORM.txtID.value;
numDigitsInID = FORM.txtID.value.length;
bPass = true;
if (ID == "" || numDigitsInID != 8 || isNaN(ID)) {
alert ("ID should be 8 digits \n Example: 10666088"
document.FORM.txtID.focus();
bPass = false;
}
return bPass;
}
The rst() function used to clear the textbox:
function rst() {
FORM.txtWWID.value = "";
document.FORM.txtWWID.focus();
}
The Submit image works AOK, although I have no idea why! The problem is with the Reset image. Some examples: If I don't enter anything into the textbox and click the Reset image, I get the alert that the ID should be 8 digits, but I'm NOT calling the validateID() function, I'm calling the rst() function! The strangest thing is that if I enter a VALID 8-digit ID, I still get the alert.
I've tried all sorts of things...I read that onclick="document.FORM.submit() submits a form so I unsuccessfully tried using onclick="document.FORM.reset()" to reset the form. I've tried using buttons of type="reset" with the image as the backgroud. But I had trouble with the sizing. If I move the Reset image outside the /FORM tag, then the correct function is called! But I can't get the buttons positioned next to each other.
I think this would just about drive anyone crazy! Newbie here (you can probably tell from my code and the issues I'm experiencing). Please help explain what is going on. =)
Peggy