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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript not working in firefox

Status
Not open for further replies.

Brianfree

Programmer
Feb 6, 2008
220
GB
Hi, im a little stuck and need to figure out to get the following working in IE & Firefox..

Code:
<script language="javascript" type="text/javascript">
function checkVINValue()
{
	if (document.coresearch.VIN.value == "" || !document.coresearch.VIN.value.match(/^[0-9a-z]+$/i))
	{	
		document.coresearch.SubmitButton.disabled=true;
		//alert('Please enter a valid UK / Irish Numberplate.');
	} else {
		document.coresearch.SubmitButton.disabled=false;
	}
}
</script>

Can anyone advise?

Many thanks,

Brian
 
Based on prior experience, and because you've shown us none of your HTML:

- Do you have a form with a name (or ID) attribute of 'coresearch' ?

- Does that form have an element inside it with a name (or ID) attribute of 'VIN' ?

If not, correct that first.

Either way, you are short-cutting the form access. Personally, I'd always go through the 'forms' collection (or use getElementById, etc):

Code:
document.forms['coresearch']

If after all that it still "doesn't work", then help us to help you by at least telling us some basics like:

- How it doesn't work

- What it does do that it shouldn't do

- What it doesn't do that it should do

- What your HTML is

... you know - all the basic things that might help someone trying to debug a problem.

Hope this helps,

Dan


Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Snippets & Info:
The Out Atheism Campaign
 
P.S. Won't that regular expression fail if users enter a space character? Most people I've asked said they would enter theirs with a space in - I certainly would - so perhaps you should either:

- relax that restriction. or
- strip out spaces first

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Snippets & Info:
The Out Atheism Campaign
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top