Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validation functions

Status
Not open for further replies.

alsaffar

Programmer
Oct 25, 2001
165
KW
Hi there,

I have a problem in calling 2 functions to validate a form input onSubmit, please help me. I simulate my script in a sample script, please take a look:

<script language='javascript'>
function Validate1()
{
if (document.all.Name.value == '')
{
alert('Name is required');
return false;
} else return FilterBadWords(document.all.Name);
return true;
}
function Validate2()
{
if (document.all.Email.value == '')
{
alert('Email is required');
return false;
} else return FilterBadWords(document.all.Email);
return true;
}
function FilterBadWords(FieldName)
{
if (FieldName.value.indexOf('XXX') != -1)
{
alert('XXX is a Bad word!');
return false;
}
return true;
}
</script>
<form action='Action.html' method='post' onSubmit="return Validate1(); return Validate2();">
<input name='Name'>
<input name='Email'>
<input type='submit' value='Send'>
</form>
 
try:

onSubmit="return (Validate1() && Validate2());"

--Dave
 
You are outstanding! Its working perfectly :) Thanx alot man.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top