Jump to content

Form Validation


Bavilo

Recommended Posts

Hello,

I have a form which submits info and emails it to me. I have a few fields that should only take numerical values, such as the zip code field, and phone number field. Is there anyway i can validate those fields and give an error if anything besides numbers have been entered?

Thanks in advance
Link to comment
Share on other sites

[!--quoteo(post=354097:date=Mar 11 2006, 10:20 PM:name=Prismatic)--][div class=\'quotetop\']QUOTE(Prismatic @ Mar 11 2006, 10:20 PM) [snapback]354097[/snapback][/div][div class=\'quotemain\'][!--quotec--]
[code]<?php
if (!is_numeric($_POST['field']){
    echo "Not a number!";
}
else{
    echo "Number!";
}
?>[/code]
[/quote]

Thanks i will try that in a bit
Link to comment
Share on other sites

[!--quoteo(post=354107:date=Mar 12 2006, 06:51 AM:name=Bavilo)--][div class=\'quotetop\']QUOTE(Bavilo @ Mar 12 2006, 06:51 AM) [snapback]354107[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Schweeeet it works great. Thanks!
[/quote]

You can also use JScript as a validation tool before submit..
Link to comment
Share on other sites

[!--quoteo(post=354126:date=Mar 12 2006, 02:12 AM:name=keeB)--][div class=\'quotetop\']QUOTE(keeB @ Mar 12 2006, 02:12 AM) [snapback]354126[/snapback][/div][div class=\'quotemain\'][!--quotec--]
You can also use JScript as a validation tool before submit..
[/quote]

Yes. But never rely on client side validation. If youre going to validate it on the client, you should still validate on the server side.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.