1 Replies - 7514 Views - Last Post: 02 December 2008 - 02:09 AM

#1 kk1990  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 01-December 08

Separate Javascript code from html file

Post icon  Posted 02 December 2008 - 12:02 AM

I have Javascript code like below. I want to separate javascript code from html File.
Can anyone tell me how to separate??
<html>
<body>
<script type="text/javascript">
function noNumbers(e)
{
var keynum;
var keychar;
var numcheck;

if(window.event)
  {
	
  keynum = e.keyCode;
  }
else if(e.which)
  {
  keynum = e.which;
  }
keychar = String.fromCharCode(keynum);
return !numcheck.test(keychar);
}
</script>

<form>
<input type="text" onkeypress="return noNumbers(event)" />
</form>

</html> 


Is This A Good Question/Topic? 0
  • +

Replies To: Separate Javascript code from html file

#2 Zichlone  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 16
  • Joined: 13-August 08

Re: Separate Javascript code from html file

Posted 02 December 2008 - 02:09 AM

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


Just replace filename with the name of your javascript file (.js is the extension)
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1