Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,471
There are 1937 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     Javascript :

quick javascript help

Thread title: quick javascript help
Closed Thread    
    Thread tools Search this thread Display Modes  
10-29-2007, 01:13 PM
#1
ojoty is offline ojoty
Status: I'm new around here
Join date: Oct 2007
Location:
Expertise:
Software:
 
Posts: 4
iTrader: 0 / 0%
 

ojoty is on a distinguished road

  Old  quick javascript help

I have a field called field@code1 in a form in a XSL page.

i want to use java script to do validation.

the javascript errors if there is a @ in it.

1. is there any way of putitng an @ in javascript
2. is there any other way i can referance the field.

thanks
_________________
Florida Golf Communities credit cards for ok credit

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>

Closed Thread    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed