Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

54 users online



Validating functions

Validating functions

Currently viewing this thread: 1 (0 members and 1 guests)


alsaffar

alsaffar

Neverside Newbie
Status: Offline!

Validating functions

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:

PHP:

<?php

<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>
?>

eric6889

eric6889

Neverside Newbie
Status: Offline!

I don't see any reason why you would need two functions. It might be better to just combine them, or call the second function from the first function.

___________________

Oh, yes, this is going to be wild.

Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0167 seconds.