external js&jquery file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • redPenOnly
    New Member
    • Mar 2010
    • 1

    #1

    external js&jquery file

    I created an html try.html file and js file func.js. every thing runs right, except it doesn't 'read' the following kind of functions:

    Code:
    <input type = "text"  id="firstName" value="first name" onkepress=nameCheck(event)"/>
    the function in func.js is defined as follows:

    Code:
    function nameCheck(event){
        var ascii = event.charCode? event.charCode:event.keyCode;
    	if ((ascii >= 48) && (ascii <= 57)){
    		alert("don't type a digit!");
    		event.returnValue = false;
    	}
    }
    the js file is declared in the head part:

    Code:
    <head> 
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="tikun.js"></script>
    </head>
    I also tryed declaring the function in the js file this way:

    Code:
    $('document').ready(function(){
    function nameCheck(event){......}
    });
    can anyone help me anderstand why it doesn't work?
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    there should be errors listed in the error console.

    at least I can say, that the last one wouldn’t work anyway.

    Comment

    Working...