I wrote a form-based web CGI in Perl and needed some field validation. So I picked this up from the web since I've never written any JS.
It sez it's supposed to work in IE and NS, but it only works in IE 5x (win/mac) and IE6 (win). It fails silently on all versions of NS4x and 6x that I've tried!
Here's a sample routine:
function validRequired(formField,fieldLabel)
{
var result = true;
if (formField.value == ""
{
alert('Please enter a value for the "' + fieldLabel +'" field.');
formField.focus();
result = false;
}
return result;
}
function validateForm(theForm)
{
if (!validRequired(theForm.fullname,"Name"
)
return false;
if (!validNum(theForm.yearsexperience,"Years Experience",true))
return false;
return true;
}
called as onsubmit="return validateForm(this)"
Anyone have any ideas?
My needs are pretty simple really. I have certain required fields, and some others that need to be numeric only ...
TIA. philc
It sez it's supposed to work in IE and NS, but it only works in IE 5x (win/mac) and IE6 (win). It fails silently on all versions of NS4x and 6x that I've tried!
Here's a sample routine:
function validRequired(formField,fieldLabel)
{
var result = true;
if (formField.value == ""
{
alert('Please enter a value for the "' + fieldLabel +'" field.');
formField.focus();
result = false;
}
return result;
}
function validateForm(theForm)
{
if (!validRequired(theForm.fullname,"Name"
return false;
if (!validNum(theForm.yearsexperience,"Years Experience",true))
return false;
return true;
}
called as onsubmit="return validateForm(this)"
Anyone have any ideas?
My needs are pretty simple really. I have certain required fields, and some others that need to be numeric only ...
TIA. philc