Click to See Complete Forum and Search --> : Problem with validation function


OhLordy
05-15-2003, 11:17 AM
Hi I have the following script in an included file called validation.js

alert("here we are now");

function checklength(s,l) {
if(s.value<l) {
alert("This field must be at least ".l." character(s) long");
return false;
} else {
return true;
}
}

then in the actual file i have a form, and on one of the form elements I have

<input type="text" name="name" value="<?=$row_main["product_name"]?>" onBlur="checklength(this.value);">

Now I don't get an alert saying "here we are now" when I load the page up, so does this mean that the file is not getting loaded at all?
Thank you in advance
Rob

Nevermore
05-15-2003, 11:31 AM
Try calling it as a function from an onload event in the body tag.

OhLordy
05-15-2003, 11:43 AM
I've found out that it is loading the file but I'm getting an error "Expected identifier" I'm not entirely sure what that means, in fact I'm entirely unsure of what that means.
Thanks in advance
Rob

Nevermore
05-15-2003, 11:48 AM
COuld you post the whole code or a link to the page.

OhLordy
05-15-2003, 11:55 AM
it's a php page made up of a number of different files.

this is validate.js

// JavaScript Document

alert("here we are");

function checklength(s,le) {
if(s.value<l) {
alert("This field must be at least ".l." character(s) long");
return false;
} else {
return true;
}
}

function check_int(s) {
if(!isaPosNum(s.value)) {
alert("This field must be a number");
return false;
} else {
return true;
}
}
[PHP]

This is http_head.php
[PHP]
<html>
<link rel="stylesheet" type="text/css" href="../../../../stylesheets/style_mainten_index.css" title="stylesheet">
<script language="JavaScript" src="../validation.js">
</script>
<title>WOW Woman Maintenance Area</title>
<body>
<div id="center">


here is the form line input line from edit_size.php the whole code is about 80 lines long

<td><input type="text" name="name" value="<?=$row_main["display_name"]?>" onBlur="checklength(this.value,'1'); "></td>


Thank You
Rob