Jump to content

[SOLVED] grr..."simple" form validation?


justravis

Recommended Posts

i'm just trying to check 1 select menu at this point...it doesnt even trigger

 

<script src='intro.js'></script>
<form method=post action=/programs/dmd/mentee/intro.pwr onSubmit='return validForm()'>
<input name=required id=required type=hidden value='chan,subchan'>
<label>How did you hear about Disability Mentoring Day?<br />
<select name='chan' onChange='showSubchan(this.value)'>
<option value=''>
	Please choose.
</option>
<option value=2>
	 San Diego Community College District
</option>

<option value=3>
	 San Diego Unified School District
</option>
</select>
<br />
<div id='selectSubchan'></div></label>
<input name=next id=next type=submit value=Next>
</form>

 

javascript

function validForm(form)
{
elem=document.getElementByID('chan');

if(elem.value == "Please Choose")
{
	alert(helperMsg);
	elem.focus();
	return false;
}
else
{
	return true;
}
}

 

Any thoughts?

 

THANK YOU!

Link to comment
https://forums.phpfreaks.com/topic/65776-solved-grrsimple-form-validation/
Share on other sites

made a few corrections:

 

<script src='intro.js'></script>
<form method=post action=/programs/dmd/mentee/intro.pwr onSubmit='return validForm()'>
<input name=required id=required type=hidden value='chan,subchan'>
<label>How did you hear about Disability Mentoring Day?<br />
<select name='chan' onChange='showSubchan(this.value)'>
<option value=''>
	Please choose.
</option>
<option value=2>
	 San Diego Community College District
</option>

<option value=3>
	 San Diego Unified School District
</option>
</select>
<br />
<div id='selectSubchan'></div></label>
<input name=next id=next type=submit value=Next>
</form>

 

function validForm()
{
var elem=document.getElementById('chan');

if(!elem.value)
{
	alert('chan');
	elem.focus();
	return false;
}
else
{
	return true;
}
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.