Chad Gary 0 Newbie Poster

I'm currently using prototype framework to validate whether or not a field is has data. When the field is empty and the user hits the form submit button the intended alert message box comes up, but after you hit OK on the message box it submits the form anyway, which I don't want to happen. Can you help Please

HTML

<script type="text/javascript" src="../Javascript/test.js">


</script>

<body>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" id="entry" method="post">
<h2>Edit Credential Category</h2>
<table id="edit">
<table>
<tr>
<td><label>Credential Category:</label></td>

<td><input type="text" id="credential_cat" maxlength=40 name="credential_cat" size="40" value="<?php echo $credential_cat; ?>" /></label><br /></td>
</tr>
</table>
<input name="id" type="hidden" value="<?php echo $id; ?>" /><br/>
<input name="submit" type="submit" value="Edit" />

</form>

Prototype Javascript Code:

function submitEntryForm(event)
{
	
	
	if ($('credential_cat').value==null||$('credential_cat').value=="")
		{
		alert('Must Enter Data');
		return false;
		}else
		{
		return true;
		}	
		
}

function addOb()
{
	$('entry').observe('submit', submitEntryForm);
}

Event.observe(window, 'load', addOb);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.