SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: Validate form

  1. #1
    SitePoint Zealot
    Join Date
    Jun 2001
    Location
    Jakarta
    Posts
    156
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Validate form

    I'm trying to make a simple shopping cart. In my shop page, there are only 6 product. Visitor can type how many item each they want to buy. After that the page redirect to ShareIt to be process.
    What I want to ask is :
    - Is there anyway to validate input only numeric ?
    - How can I check the form, so only valid value will be send to ShareIt.

    The link would be like : http://shareit1.*************/cart.html?product[A1]=quantity+product[A2]=quantity.....

    So if the quantity value 0 (or characters), it will not send to ShareIt.
    Thanks for any help.

  2. #2
    SitePoint Zealot
    Join Date
    Jun 2001
    Location
    Jakarta
    Posts
    156
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry, there is mistype.

    http://shareit1.*************/cart.html?product[A1]=quantity&product[A2]=quantity.....

  3. #3
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi jet_wang,

    The isNaN() will tell you if a value is a number or not; it would be used as such:

    if (isNaN(quantity) ) alert("you must enter a number.");

    If you would like to see how you can validate a form for all types of form elements, see the "Validating Forms" script/tutorial at my site

    Vinny
    Last edited by Vincent Puglia; Aug 23, 2001 at 09:01.
    Where the World Once Stood
    the blades of grass
    cut me still

  4. #4
    Don't eat yellow snow spaceman's Avatar
    Join Date
    Mar 2001
    Location
    Melbourne, Australia
    Posts
    1,039
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I do my form validation using PHP _after_ the user has submitted the form.

    But I was wondering... is it possible (using javascript, I guess) to restrict an HTML form input field in such a way that it's not possible to type anything but 0-9? That would be useful...
    Web Design Perth Melbourne .:. Itomic Business Website Solutions
    Drupal Experts .:. Drupalise


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
  •