Welcome to Tech Support Forum home to more then 136,000 problems solved. Issues have included: Spyware, Malware, Virus Issues, Windows, Microsoft, Linux, Networking, Security, Hardware, and Gaming Getting your problem solved is as easy as:
1. Registering for a free account
2. Asking your question
3. Receiving an answer

Registered members:
* Get free support
* Communicate privately with other members (PM).
* Removal of this message
* See fewer ads.
* And much more..

 



Want to know how to post a question? click here Having problems with spyware and pop-ups? First Steps
Go Back   Tech Support Forum > Design Forum > Web Design & Programming
User Name
Password
Site Map Register Donate Rules Blogs Mark Forums Read


Web Design & Programming Discussion of web design, and server-side & client-side scripting

Reply
 
LinkBack Thread Tools
Old 03-31-2009, 06:23 AM   #1 (permalink)
rmb
Registered User
 
Join Date: Jul 2008
Posts: 43
OS: Windows XP Pro Service Pack 2


Send a message via Skype™ to rmb
Cry Forms > Required Fields

Looking for some help on programming required fields into my forms on my sites. I only know html and CSS and a little bit of Javascript.

I've designed a form here - http://www.stereofx.net/promo/promo.htm

I've marked some fields with a * saying that they are required fields, just to kind of fool people for now untill I can actually program it. Any help here would be greatly appreciated. I have searched a bit on the net and found it can be done with C#.net programming - but I wouldn't know where to start....

Thanks.
rmb is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Important Information
Join the #1 Tech Support Forum Today - It's Totally Free!

TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free.

Join TechSupportforum.com Today - Click Here

Old 03-31-2009, 07:32 AM   #2 (permalink)
Design Team Member
 
jamiemac2005's Avatar
 
Join Date: Jul 2007
Location: Coventry, UK
Posts: 1,876
OS: Vista, various linux distros


Re: Forms > Required Fields

Hey, you can make your fields required in JS... Heres the basics:
Imagine this in the HEAD of your page...

HTML Code:
<script language="javascript" type="text/javascript">

function validateForm(){
  //if this function returns false to the onsubmit event the form will not submit, if it returns true it will submit.

//so get the fields:
var nameField = document.getElementById("namefield");
//I'm using namefield as an example above, do the same for all the other required fields

//then check that the value isn't "" (and empty string)
if(nameField.value == ""){
  //if it is blank
  //return false to stop the form from submitting
  return false;
  //you could also output some form of error (i use alert here as a basic example, personally i'd set up a div, and make it fixed in the center of the screen and have that contain the error)...
  alert("You have not entered your name");
}

//again do the same for each of the fields
//...
}

</script>
And then your form tag looking like this(This is the crutial bit):
HTML Code:
<form action="http://formmail.servage.net/" method="POST" onsubmit="validateForm();">
Right that's the general idea of it... I also suggest you go over some W3 validation, because you're working with an XHTML doctype but using some old style attributes etc...
Anyway: Have a look at this.

Cheers,
Jamey
__________________

Myspace

Last edited by jamiemac2005; 03-31-2009 at 07:37 AM.
jamiemac2005 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 04-01-2009, 03:19 AM   #3 (permalink)
rmb
Registered User
 
Join Date: Jul 2008
Posts: 43
OS: Windows XP Pro Service Pack 2


Send a message via Skype™ to rmb
Re: Forms > Required Fields

Thanks Jamey. The JS seems a little hectic but will definitely give it a go. Should take me a few days to come right.

As for the errors on my page, well, dreamweaver is righting the code for me and as long as it works I'm happy. I don't know how to fix (or rather prevent) dreamweaver from putting in old/incorrect code.

Since I'm on the topic of dreamweaver... I have just upgraded to Dreamweaver CS3 from version 8, and I've put in my webpages and now they are showing as if the images are left-aligned, but in fact are programmed as centre aligned. If I preview in browser it's ok, but in the actual program I can't seem to get the images to show centre or right aligned. This is really starting to agrevate me.

Screenshot - http://www.stereofx.net/images/dw_screenshot.jpg
webpage - http://www.stereofx.net/html/music.htm

On a final note, what is the code I need in order to have a favicon on my site? Would I have to use the code on all my pages in order for it to show on all pages of the site?

Thanks in advance.
rmb is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 04-01-2009, 05:35 AM   #4 (permalink)
Design Team Member
 
jamiemac2005's Avatar
 
Join Date: Jul 2007
Location: Coventry, UK
Posts: 1,876
OS: Vista, various linux distros


Re: Forms > Required Fields

Okay, if you come up against any problems whilst writing the rest of the JS feel free to post for more help because i'm happy to give you a hand on this form.

Ouch, i didn't know dreamweaver was that bad at coding... If i get the time later today i'll take a look over your site and help you validate it.

Quote:
as long as it works I'm happy.
You'll find that in certain browsers this will not work.

Again with the images problem i believe the problem is how DW8 coded your site. I'll have a look later to give you a hand.

As for the favicon, you can just place a file called "favicon.ico" in your server root in most cases but it's best to add these two meta tags to the HEAD of your page:
HTML Code:
<link rel="icon" href="http://www.domain.com/favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="http://www.domain.com/favicon.ico" type="image/x-icon"> 
Cheers,
Jamey
__________________

Myspace
jamiemac2005 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 04-01-2009, 04:09 PM   #5 (permalink)
rmb
Registered User
 
Join Date: Jul 2008
Posts: 43
OS: Windows XP Pro Service Pack 2


Send a message via Skype™ to rmb
Re: Forms > Required Fields

Point taken, I do need to try make sure everything is perfect. Got the favicon up, thanks...

If you do get a chance to look at the site validation lets start with the home page http://stereofx.net

27 errors here :(
rmb is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -7. The time now is 12:32 PM.



Copyright 2001 - 2009, Tech Support Forum
Home Tips Plus | Outdoor Basecamp | Automotive Support Forum

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85