Bruce Gust
asked on
How to use Javascript to validate two fields before form submission?
Here's my code:
It works great, as far as validating the social icon list, but I need to validate the URL field as well. Can I use the same kind of scripting that I have in place to validate two fields and not just the one?
<table cellspacing="0" cellpadding="0" style="margin:auto;"><form action="link_insert_execute.php" method="Post">
<tr>
<td>
Link Type
</td>
<td class="standard">
<script type='text/javascript'>
function none_Empty(elem, helperMsg){
if(elem.value.length == 0){
alert(helperMsg);
elem.focus();
return false;
}
}
</script>
<select name="link_type" id='req3'/>
<option></option>
<option>facebook</option>
<option>google plus</option>
<option>instagram</option>
<option>itunes</option>
<option>linked in</option>
<option>myspace</option>
<option>store</option>
<option>twitter</option>
<option>webpage</option>
<option>youtube</option>
<option>______________________________</option>
</select>
</td>
</tr>
<tr>
<td>
URL
</td>
<td>
<input type="text" size="35" name="url" id='req4'/>
</td>
</tr>
<tr>
<td align="center" colspan="2"> <BR>
<input type="hidden" name="registration_id" value="<?php echo $novie_id; ?>">
<input type="submit" value="submit" onclick=" return none_Empty(document.getElementById('req3'), 'Please submit an icon type in the logo field.')" value='Check Field' />
</td>
</tr>
</table>
It works great, as far as validating the social icon list, but I need to validate the URL field as well. Can I use the same kind of scripting that I have in place to validate two fields and not just the one?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.