View Single Post
11-14-2007, 08:49 AM
#2
fluxister is offline fluxister
Status: I'm new around here
Join date: Nov 2007
Location:
Expertise:
Software:
 
Posts: 1
iTrader: 0 / 0%
 

fluxister is on a distinguished road

  Old

Are you after something such as the following? where if no @ symbol is entered an error message will appear.

HTML Code:
<html>

<head>

<title> </title>

<script type="text/javascript">
function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
  {alert(alerttxt);return false}
else {return true}

}
}

function validate_email(field,alerttxt)
{
with (field)
{
apos=value.indexOf("@")
if (apos<1) 
  {alert(alerttxt);return false}
else {return true}
}
}


function form_validate(thisform)
{
with (thisform)
{
if (validate_email(mail,"You have not entered a valid email address!")==false)
  {mail.focus();return false}
}
}
</script>
</head>

<body>
<form action="valid_check.php"
onsubmit="return form_validate(this)"
method="post">
<table>

<tr>
<td>Email address:</td>
<td><input type="text" name="mail"></td>
</tr>

<tr>
<td> </td>
<td><input type="submit" value="Sign Up"></td> 
</tr>

</table>
</form>

</form>
</body>

</html>
Or are you saying that if someone enters an @ symbol you want an error message to appear?

HTML Code:
<html>

<head>

<title> </title>

<script type="text/javascript">
function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
  {alert(alerttxt);return false}
else {return true}

}
}

function validate_email(field,alerttxt)
{
with (field)
{
apos=value.indexOf("@")
if (apos>1) 
  {alert(alerttxt);return false}
else {return true}
}
}


function form_validate(thisform)
{
with (thisform)
{
if (validate_email(mail,"You have not entered a valid email address!")==false)
  {mail.focus();return false}
}
}
</script>
</head>

<body>
<form action="valid_check.php"
onsubmit="return form_validate(this)"
method="post">
<table>

<tr>
<td>Email address:</td>
<td><input type="text" name="mail"></td>
</tr>

<tr>
<td> </td>
<td><input type="submit" value="Sign Up"></td> 
</tr>

</table>
</form>

</form>
</body>

</html>