Hi All,

I am by no means a JS expert and I am setting up form validation on my website. I got most of the validation elements working except for one particular field.

There is a text field in the form called "Group Size". It can't be a number field because sometimes people would enter text like "Approx 20 people", or "40-50". But I am getting some sort of spammy submissions on my form and they will usually put a group size of 1 or 2 or 5. And the email addresses are fake for sure. Anyway, I want to screen these out, so how do I do that? I've also appended the form code.

The conditions I want for the group size field are:
- If the group size field has a length of 1 AND
- The value of the field is less than 6
Then the script returns false and the alert pops up.

Thanks in advance!

Here is the JS and I have highlighted the part that I am stuck on.

function validation(form) {

if(form.first_name.value == '') {

alert('Please enter your first name');
return false;

if(form.last_name.value == '') {

alert('Please enter your last name');
return false;

if(form.company.value == '') {

alert('Please enter your company or organization. *** We do not serve private groups such as birthday parties, wedding parties or other social events ***');
return false;

if(form.email.value == '') {

alert('Please enter your email address');
return false;

if (Number(form.00NG0000008iHKH.value) < 6 && form.00NG0000008iHKH.length == 1)

alert('Sorry but we are unable to provide programs for groups of 5 or fewer. If you still want to inquire, please phone us.');
return false;

return true;


And here is the form:

<form action="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST" onsubmit="return validation(this);">

<input type=hidden name="oid" value="00DG0000000CS9I">
<input type=hidden name="retURL" value="http://www.scavengerhuntanywhere.com/resources.php">

<!-- ---------------------------------------------------------------------- -->
<!-- NOTE: These fields are optional debugging elements. Please uncomment -->
<!-- these lines if you wish to test in debug mode. -->
<!-- <input type="hidden" name="debug" value=1> -->
<!-- <input type="hidden" name="debugEmail" -->
<!-- value="andrew@greatnessgroup.com"> -->
<!-- ---------------------------------------------------------------------- -->

<label for="first_name">First Name</label><br><input id="first_name" maxlength="40" name="first_name" size="30" type="text" /><br>

<label for="last_name">Last Name</label><br><input id="last_name" maxlength="80" name="last_name" size="30" type="text" /><br>

<label for="company">Company</label><br><input id="company" maxlength="40" name="company" size="30" type="text" /><br>

<label for="email">Email</label><br><input id="email" maxlength="80" name="email" size="30" type="text" /><br>

<label for="phone">Phone</label><br><input id="phone" maxlength="40" name="phone" size="30" type="text" /><br>

Program location<br><input id="00NG0000008iHK7" maxlength="100" name="00NG0000008iHK7" size="30" type="text" /><br>

Group Size<br><input id="00NG0000008iHKH" maxlength="20" name="00NG0000008iHKH" size="30" type="text" /><br>

Event Date<br><input id="00NG0000008iHKR" maxlength="20" name="00NG0000008iHKR" size="30" type="text" /><br>

Comments / Questions<br><textarea id="00NG0000008iHKg" name="00NG0000008iHKg" rows="5" cols="50" type="text" wrap="soft"></textarea><br>
<input type="submit" name="Continue ->">