Jump to content

Numeric Validation


aris1234

how a Numeric validation ?  

1 member has voted

  1. 1. how a Numeric validation ?

    • A
      1
    • B
      0


Recommended Posts

Hi..

i have field in record using type : numeric,

 

how to make validation and i want viewing messagebox if user inputing character or empty?

 

this code just work for empty field, not for numeric type,

if(WithoutContent(document.add.sprice.value))

{ errormessage += "\n\n\"PRICE\" still Empty."; }

----------

 

this my full code:

Code: ( html4strict )

 

  1.

      <script type="text/javascript" language="JavaScript">

  2.

      <!--

  3.

      function CheckValidation() {

  4.

      var errormessage = new String();

  5.

     

  6.

      if(WithoutContent(document.add.sprice.value))

  7.

          { errormessage += "\n\n\"PRICE\" still Empty."; }

  8.

      if(WithoutContent(document.add.spropadd.value))

  9.

          { errormessage += "\n\nPROPERTY ADD still Empty."; }

  10.

      if(WithoutSelectionValue(document.add.sbed))

  11.

          { errormessage += "\n\nBED list still Empty."; }

  12.

     

  13.

      if(errormessage.length > 2 )

  14.

        {

  15.

          alert('NOTE:' + errormessage);

  16.

          return false;

  17.

          }

  18.

      return true;

  19.

     

  20.

      function WithoutContent(ss) {

  21.

      if(ss.length > 0) { return false; }

  22.

      return true;

  23.

      }

  24.

     

  25.

      function WithoutSelectionValue(ss) {

  26.

      for(var i = 0; i < ss.length; i++) {

  27.

          if(ss.selected) {

  28.

              if(ss.value.length) { return false; }

  29.

              }

  30.

          }

  31.

      return true;

  32.

      }

  33.

      //--> 

  34.

      </script>

  35.

      .

  36.

      .

  37.

      .

  38.

      <form name="add" onsubmit="return CheckValidation()" action="inputing.php" method="POST" enctype="multipart/form-data">

 

that code only to blank or empty field.. how to validation for price (numeric type) in code above ??

thank b4.

Link to comment
https://forums.phpfreaks.com/topic/54840-numeric-validation/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.