Hi guys,
I need your help with this problem , I checked the braces but it’s still not working.
Basically the code is based on 2 functions ( isNameOk,MainValidate ) to validate one input text triggered with OnBlur handler calling isNameOk function and passing “this” and getElementById of the span elemet (where the error msg will apear)
then isNameOk function passes (regex + input value + span ID + “error msg”) to MainValidate function were it checks the regex and decide to display error or not .
and when I run it , I get isNameOk function is not defined from the firefox error console !
i hope you get what I’m trying to do
[CODE]<html>
<head>
<script type=”text/javascript” src=”JavaScript.js”>
function MainValidate(regex, typed, errorId, Msg)
{
if (!regex.test(typed))
{
if (errorID != null)
while (errorID.firstChild)
{
errorId.removeChild(errorId.firstChild);
}
errorId.appendChild(document.createTextNode(Msg));
return false;
}
else
{
if (errorID != null)
{
while (errorID.firstChild)
{
errorID.removeChild(errorID.firstChild);
}
return true;
}
}
}
function isNameOk(input, errorID)
{
regex = /^[A-Za-z -]{2,10}s?([A-Za-z -]{2,10})?/
return MainValidate(regex, input.value, errorID, ” please enter valid name”);
}
</script>
</head>
<body>
<div>
Name :
<input id=”Name” type=”text” size=”20″ onblur=”isNameOk(this, document.getElementById(‘name_error’))” />
<span id=”name_error”></span>
</div>
</body>
</html>