Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why wont this work? function

Status
Not open for further replies.

itsnickj

Technical User
May 2, 2008
2
US
Again, I'm trying to validate a form, in my fields i have onblur="validate_form()"

and the function is:

<script type="text/javascript">

<!--

function validate_form()
{
valid = true;
if (document.form.name.var RegExp/^[A-Za-z]/)
{
alert ( "please enter a valid name." );
valid = false;
}

return valid;
}
//-->
</script>
 
This is the function that you've decided would be best to implement on your site? Who wrote it? It doesn't look like anything that would work.


----
star.gif
 
<script language="JavaScript" type="text/JavaScript">
function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
{alert(alerttxt);return false;}
else {return true}
}
}
function validate_form4(thisform)
{
with (thisform)
{
if (validate_required(Agent_Empid4,"Agent Name Required!")==false)
{Agent_Empid4.focus();return false;}
}
}
</script>

//Put this on your form field//
<form name="myform" onSubmit="return validate_form4(this);">
<input name="Agent_Empid4" type="text" id="Agent_Empid4" size="100" maxlength="100" onblur="return validate_form4(this)">
</form>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top