Web Analytics Made Easy -
StatCounter Soooo frustrated - CodingForum

Announcement

Collapse
No announcement yet.

Soooo frustrated

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Resolved Soooo frustrated

    I'm using a simple Javscript function.
    isNaN - Of course, this is supposed to tell me if a field is a number or not, the problem is, It's ALWAYS RETURNING TRUE!!!

    Code:
    function validate_form(thisform)
    {
    	with (thisform)
    	{
    		if (isNaN(pquant))
    		{
    			alert("Test");
    			return false;
    		}
             }
    }
    is a little piece of my function, here's my form:
    Code:
        <form onsubmit="return validate_form(this)" method="post" action="form.php">
            <input name="pquant" type="text" value="Product Quantity" size="40" />
    Last edited by The Midnighter; Apr 7, 2009, 02:43 PM.

  • #2
    I've also looked on Google for a different variation of isNaN, I found:
    Code:
    function IsNumeric(sText)
    {
       var ValidChars = "0123456789.";
       var IsNumber=true;
       var Char;
    
     
       for (i = 0; i < sText.length && IsNumber == true; i++) 
          { 
          Char = sText.charAt(i); 
          if (ValidChars.indexOf(Char) == -1) 
             {
             IsNumber = false;
             }
          }
       return IsNumber;
       
       }
    That, used with the same form, still always returns false regardless.
    Am I missing something completely?

    Comment


    • #3
      I was missing something completely.
      Totally didn't take into account that pquant is just an object, pquant.value was the bulls-eye.

      Comment

      Working...
      X