Hi I have below javascript code

<SCRIPT language="javascript">
function validate(){
	if(document.r_requisition.r_project_name.value=="deny"){
	alert ("You are not authorised to any project ");
	return false;
	}
	if(document.r_requisition.r_number.value==""){
	alert ("input in req No.");
	return false;
	}
	if(document.r_requisition.r_delv_date.value==""){
	alert ("input Delivery Date: ");
	return false;
	}
	
}
</script>

Its working fine. But when I saved this file and write to my document header section

<script type="text/javascript" src="js/r_validate.js"></script>

its not working. can anybody solve this

Try:

<script type="text/javascript" src="js/r_validate.js" language="javascript"/>

Have u tried accessing the script directly in the browser, by calling the file in the browser? cause sometimes you are just not accessing the file, the location of the file could be incorrect. maybe it is another level up, also ensure that the file is saved the same way u are calling it.

I know the above sounds silly and one cannot possibly have gotten that wrong, but we are human and make mistakes, sometimes its just the simple things we get wrong

Hi I have below javascript code

<SCRIPT language="javascript">
function validate(){
	if(document.r_requisition.r_project_name.value=="deny"){
	alert ("You are not authorised to any project ");
	return false;
	}
	if(document.r_requisition.r_number.value==""){
	alert ("input in req No.");
	return false;
	}
	if(document.r_requisition.r_delv_date.value==""){
	alert ("input Delivery Date: ");
	return false;
	}
	
}
</script>

Its working fine. But when I saved this file and write to my document header section

<script type="text/javascript" src="js/r_validate.js"></script>

its not working. can anybody solve this

Don't forget to remove the <script...> tags from the source file!

1. As Troy III said, you are not supposed to have 'script' tag inside a .js file. If you have it, remove it.
2. Where is the .js file? Is it in where it is supposed to be -- js folder? Assuming your HTML file is in folder 'myHTML', your js file should be in 'myHTML/js' folder.
3. Your js code is hard-coded -- calling DOM directly. Make sure that all elements match those that are referring by your js code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.