Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-24-2013, 12:39 PM   PM User | #1
Rowan88
New to the CF scene

 
Join Date: Jan 2013
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Rowan88 is an unknown quantity at this point
Make Fields Validate On Submit?

Hi,

I just finished creating my Contact Us Form and it all works perfectly. The only problem I have is that you can type whatever you want in the fields and it sends.

Can someone please show me how I can make the fields I have * next to required and also that they are putting the right stuff in the field (ie email not in a telephone field).

I use dreamweaver cs6 and heres my form code:

Code:
<form id="contactformsend.php" name="form1" method="post" action="contactformsend.php">
  <table width="360" border="0" cellpadding="5">
    <tr>
      <td class="contactheaders"><label for="name">Full Name : <span class="astrix">*</span></label></td>
      <td width="197"><input name="name" type="text" id="name" size="34" /></td>
    </tr>
    <tr>
      <td class="contactheaders"><label for="email">Email Address : <span class="astrix">*</span></label></td>
      <td><input name="email" type="text" id="email" size="34" /></td>
    </tr>
    <tr>
      <td class="contactheaders"><label for="telephone">Telephone : </label></td>
      <td><input name="telephone" type="text" id="telephone" size="34" /></td>
    </tr>
    <tr>
      <td class="contactheaders"><label for="subject">Subject : <span class="astrix">*</span></label></td>
      <td><input name="subject" type="text" id="subject" size="34" /></td>
    </tr>
    <tr>
      <td class="contactheaders"><label for="description">Description : <span class="astrix">*</span></label></td>
      <td><textarea name="description" id="description" cols="25" rows="10"></textarea></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input type="submit" name="submit" id="submit" value="Submit" />
      <input type="reset" name="reset" id="reset" value="Reset" /></td>
    </tr>
  </table>
</form>
Thanks,
Rowan88 is offline   Reply With Quote
Old 01-24-2013, 01:53 PM   PM User | #2
teedoff
Senior Coder

 
Join Date: Aug 2010
Location: High Point, NC
Posts: 3,325
Thanks: 5
Thanked 363 Times in 360 Posts
teedoff is on a distinguished road
You would need to use server side language such as ColdFusion, php, asp.net and the like, to safely validate form inputs. You can also use JavaScript along with a server side.
__________________
Teed
teedoff is offline   Reply With Quote
Old 01-24-2013, 02:00 PM   PM User | #3
Rowan88
New to the CF scene

 
Join Date: Jan 2013
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Rowan88 is an unknown quantity at this point
Could you point me in the direction of some sort of guide? It took me long enough to make the contact form and get it working I dont want to screw it up lol.
Rowan88 is offline   Reply With Quote
Old 01-24-2013, 02:07 PM   PM User | #4
jerry62704
Senior Coder

 
jerry62704's Avatar
 
Join Date: Oct 2007
Location: Springfield, IL
Posts: 1,046
Thanks: 9
Thanked 81 Times in 81 Posts
jerry62704 is on a distinguished road
Start at the free tutorial, http://www.w3schools.com/js/js_intro.asp.

What you are after is form validation and it can be done on your machine (and should be). The idea is to minimize any connection to the server.

There is a javascript forum here in codingforums.
__________________
.
.
...and gladly would he learn and gladly teach

Visit www.LiberalsWin.com for humor and the unique Bush/Obama Approval Polls
jerry62704 is offline   Reply With Quote
Old 01-24-2013, 03:18 PM   PM User | #5
teedoff
Senior Coder

 
Join Date: Aug 2010
Location: High Point, NC
Posts: 3,325
Thanks: 5
Thanked 363 Times in 360 Posts
teedoff is on a distinguished road
Dont use javascript alone to validate form fields. Savvy users can highjack your forms and enter whatever they want...including malicious code.

If you are using DW and you dont have a few months to learn a server side language, DW has build in form tools that add server side validation. I dont like or recommend using DW tools vs hand coding, but in a pinch they work well enough.

You'll need to set up a server on your pc, whether php or coldfusion server its up to you.
__________________
Teed
teedoff is offline   Reply With Quote
Old 01-24-2013, 04:00 PM   PM User | #6
jerry62704
Senior Coder

 
jerry62704's Avatar
 
Join Date: Oct 2007
Location: Springfield, IL
Posts: 1,046
Thanks: 9
Thanked 81 Times in 81 Posts
jerry62704 is on a distinguished road
Jim? Out west? Only Teed I know.
__________________
.
.
...and gladly would he learn and gladly teach

Visit www.LiberalsWin.com for humor and the unique Bush/Obama Approval Polls
jerry62704 is offline   Reply With Quote
Old 01-24-2013, 04:09 PM   PM User | #7
teedoff
Senior Coder

 
Join Date: Aug 2010
Location: High Point, NC
Posts: 3,325
Thanks: 5
Thanked 363 Times in 360 Posts
teedoff is on a distinguished road
Quote:
Originally Posted by jerry62704 View Post
Jim? Out west? Only Teed I know.
?? lol You know another guy named Teed? Nope I'm in North Carolina.
__________________
Teed
teedoff is offline   Reply With Quote
Old 01-24-2013, 04:20 PM   PM User | #8
Frankie
Regular Coder

 
Join Date: Sep 2011
Posts: 284
Thanks: 3
Thanked 32 Times in 32 Posts
Frankie is an unknown quantity at this point
Quote:
Originally Posted by Rowan88 View Post
Could you point me in the direction of some sort of guide? It took me long enough to make the contact form and get it working I dont want to screw it up lol.
Hey Rowan,

Sure, there are several: https://www.google.nl/search?q=how+t...+form+with+php. I haven't tried 'em, but with their help you should be able to get the job done. As for setting up a server on your own computer, that is not necessary if you furthermore do not use php. You can test it online instead.

Good luck.
__________________
Frank

How to: Target IE in, Position in, Center in, Create a Fixed ('Sticky') Footer with, and Create a Drop-Down/Fly-Out Menu with CSS: Website Laten Maken Amsterdam.

Last edited by Frankie; 01-24-2013 at 05:04 PM..
Frankie is offline   Reply With Quote
Old 01-24-2013, 06:17 PM   PM User | #9
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,448
Thanks: 0
Thanked 496 Times in 488 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
How to validate your form will depend on which server side validation you have avaliable to do the validation. Any validation you do in JavaScript is for the convenience of the person filling out the form, they can bypass it if they want to.
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/
felgall is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:33 PM.


Advertisement
Log in to turn off these ads.