Results 1 to 2 of 2

Thread: javascript validaion problem

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2006
    Posts
    33

    javascript validaion problem

    i am new in programming i want to do validation but
    other code in my ff.js file like code for checking the empty field is working
    but the below one for checking numeric fields not working
    ph_r2 is text field where i want to enter the numeric only since it is for phone no
    if (!isNum(document.frmemp.ph_r2.value))
    {
    alert("Pl Enter Numeric Values")
    document.frmemp.ph_r2.focus();
    return false;
    }

    p. help

  2. #2
    Addicted Member
    Join Date
    Jan 2007
    Posts
    143

    Re: javascript validaion problem

    well, this code can make sure only numbers are entered during the keypress event of a form field..

    Code:
    function NumbersOnly(e) {
    	var myChar;
    	var badChar = "!@#$%^&*()-=+[]{}\\|;:'\",./<>_`~?ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz "
    	//this only allows numbers
    	
    	e = window.event;
    	myChar = String.fromCharCode(e.keyCode);
     
    	for(var j = 0; j <= badChar.length-1; j++){
    		if ( myChar == badChar.charAt(j) )
    			e.returnValue = false
    	}
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width