Hello friends: I have hit another brick-wall.

I have the following two functions in an asp.net (not MVC) page: I separated the function because I needed to use each function on an onBlur event, this will simply call individual validation/function. The validation works fine with just the onBlur event but not the combination using the button.

Example: Lets say I enter valid entries into both textboxes and click the submit button, if I go back to the textbox and re-enter a bad value, the onBlur no-longer works.

In a nutshell the onBlur only works if I do not use the button, once I do and the functions have evaluated to true, then the onBlur will not work if I re-enter a wrong value.

Note: I want to learn the basics of JavaScript before jumping into JQuery.

Thanks for your help!

Here is Function A:


Code:
function validateA() {
"use strict";

var element = document.forms["membership"];

var userNameErrorMsg = document.getElementById("lstUserNameErrorMsg");
var userNameTextbox = document.getElementById("txtUserName");
var userNameErrorFlg = document.getElementById("lblUserName");


var isLetters = /^[A-Za-z0-9]+$/;

if (element.txtUserName.value.match(isLetters) && 
element.txtUserName.value.length >= 8) {

userNameErrorMsg.setAttribute("class", "default");
userNameTextbox.className = "";
userNameErrorFlg.className = "";

return true;
}
else {

userNameErrorMsg.setAttribute("class", "error-desc");
userNameTextbox.className = "error-state";
userNameErrorFlg.className = "error-flag";

return false;
}
}
And Function B:

Code:
function validateB() {
"use strict";

var element = document.forms["membership"];

var passwordErrorDesc = document.getElementById("lstPasswordErrorMsg");
var passwordTextbox = document.getElementById("txtPassword");
var passwordErrorFlg = document.getElementById("lblPassword");


var isNumberLetters = "^[a-zA-Z0-9]*$";

if (!element.txtPassword.value.match(isNumberLetters) && 
element.txtPassword.value.length >= 8) {

passwordErrorDesc.setAttribute("class", "default");
passwordTextbox.className = "";
passwordErrorFlg.className = "";

return true;
}
else {

passwordErrorDesc.setAttribute("class", "error-desc");
passwordTextbox.className = "error-state";
passwordErrorFlg.className = "error-flag";

return false;
}
}
Finally the calling function:

Code:
function callBothFunction() {
"use strict";

var isValidFunction = validateA() && validateB();

return isValidFunction;
}
The button onClick event:

Code:
<input type="submit" name="btnSubmit" value="Submit Form"
onclick="return callBothFunction();" id="btnSubmit" tabindex="11" />

Lastly; the OnBlur event which calls individual function:

Code:
<input name="txtUserName" type="text" maxlength="16" 
id="txtUserName" tabindex="4" onblur="validateA();" />


<input name="txtPassword" type="text" maxlength="16" 
id="txtPassword" tabindex="5" onblur="validateB();" />

Can I use the onclick an onBlur together?

Thanks again!