Results 1 to 2 of 2

Thread: Validate int

  1. #1
    Join Date
    Nov 2007
    Posts
    151
    Thanks
    67
    Thanked 0 Times in 0 Posts

    Default Validate int

    Hi,

    I have a simple form with a text field

    and I want to check if it was written there a integer.

    I used is_numeric($_POST["input"]) but it accepts also double number.

    What can I do?

  2. #2
    Join Date
    Nov 2008
    Posts
    58
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Default

    use regular expression matching.
    PHP Code:
    if(!preg_match("/^[\-\+]?[\d]*$/",$_POST["input"]))
    {
    //error


    The following pages might be helpful:
    PHP Form Validation Script
    and
    JavaScript Form Validation

Bookmarks

Posting Permissions

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