#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    13
    Rep Power
    0
    I can't get numeric checking from form fields to work. The fields coming back from a form are strings so they always fail the is_int() function even if they contain an integer.

    All I want to do is check for an integer in a form field.

    Help appreciated - it's driving me crazy.

  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15

    use ereg() function for that..

    try following..this will check an integer in a string...


    <?php

    $string="ht4jhg";

    if(ereg('^(.*)[0-9]{1,}',$string)){

    echo "it is validn";
    }else{
    echo "it is not validn";
    }

    ?>


    ------------------
    SR -
    webshiju.com

    "The fear of the LORD is the beginning of knowledge..."

Similar Threads

  1. Add $ENV{REMOTE_USER} to end of textarea field on a form
    By k9barry in forum HTML Programming
    Replies: 8
    Last Post: February 4th, 2004, 02:36 PM
  2. Inserting from form to multiple tables
    By barth in forum MySQL Help
    Replies: 0
    Last Post: January 25th, 2004, 10:27 AM
  3. HTTP Error 400: Bad Request, with basic form
    By crackwombat in forum PHP Development
    Replies: 1
    Last Post: January 23rd, 2004, 07:40 PM
  4. sending form field data
    By bellcom in forum PHP Development
    Replies: 1
    Last Post: January 19th, 2004, 04:39 PM
  5. html form problem using mult select and file field
    By Justin_M in forum HTML Programming
    Replies: 4
    Last Post: January 5th, 2004, 08:13 PM

IMN logo majestic logo threadwatch logo seochat tools logo