• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 07:21
CEST 13:21
KST 20:21
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
Team Liquid Map Contest #22 - The Finalists14[ASL21] Ro16 Preview Pt1: Fresh Flow9[ASL21] Ro24 Preview Pt2: News Flash10[ASL21] Ro24 Preview Pt1: New Chaos0Team Liquid Map Contest #22 - Presented by Monster Energy21
Community News
2026 GSL Season 1 Qualifiers11Maestros of the Game 2 announced32026 GSL Tour plans announced11Weekly Cups (April 6-12): herO doubles, "Villains" prevail1MaNa leaves Team Liquid22
StarCraft 2
General
MaNa leaves Team Liquid 2026 GSL Tour plans announced Team Liquid Map Contest #22 - The Finalists Weekly Cups (April 6-12): herO doubles, "Villains" prevail Oliveira Would Have Returned If EWC Continued
Tourneys
Sparkling Tuna Cup - Weekly Open Tournament GSL CK: More events planned pending crowdfunding 2026 GSL Season 1 Qualifiers Master Swan Open (Global Bronze-Master 2) SEL Doubles (SC Evo Bimonthly)
Strategy
Custom Maps
[D]RTS in all its shapes and glory <3 [A] Nemrods 1/4 players [M] (2) Frigid Storage
External Content
Mutation # 521 Memorable Boss The PondCast: SC2 News & Results Mutation # 520 Moving Fees Mutation # 519 Inner Power
Brood War
General
ASL21 General Discussion BGH Auto Balance -> http://bghmmr.eu/ Gypsy to Korea Pros React To: Tulbo in Ro.16 Group A Data needed
Tourneys
Escore Tournament StarCraft Season 2 [Megathread] Daily Proleagues [ASL21] Ro16 Group A [ASL21] Ro16 Group B
Strategy
Simple Questions, Simple Answers What's the deal with APM & what's its true value Any training maps people recommend? Fighting Spirit mining rates
Other Games
General Games
Nintendo Switch Thread General RTS Discussion Thread Battle Aces/David Kim RTS Megathread Stormgate/Frost Giant Megathread Starcraft Tabletop Miniature Game
Dota 2
The Story of Wings Gaming
League of Legends
G2 just beat GenG in First stand
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas TL Mafia Community Thread Five o'clock TL Mafia
Community
General
Things Aren’t Peaceful in Palestine US Politics Mega-thread Russo-Ukrainian War Thread YouTube Thread Canadian Politics Mega-thread
Fan Clubs
The IdrA Fan Club
Media & Entertainment
Anime Discussion Thread [Req][Books] Good Fantasy/SciFi books [Manga] One Piece Movie Discussion!
Sports
2024 - 2026 Football Thread McBoner: A hockey love story Formula 1 Discussion Cricket [SPORT]
World Cup 2022
Tech Support
[G] How to Block Livestream Ads
TL Community
The Automated Ban List
Blogs
Reappraising The Situation T…
TrAiDoS
lurker extra damage testi…
StaticNine
Broowar part 2
qwaykee
Funny Nicknames
LUCKY_NOOB
Iranian anarchists: organize…
XenOsky
ASL S21 English Commentary…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1658 users

The Big Programming Thread - Page 324

Forum Index > General Forum
Post a Reply
Prev 1 322 323 324 325 326 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
RoyGBiv_13
Profile Blog Joined August 2010
United States1275 Posts
July 19 2013 00:14 GMT
#6461
On July 19 2013 08:44 nunez wrote:
Show nested quote +
On July 19 2013 08:08 RoyGBiv_13 wrote:
On July 19 2013 07:40 nunez wrote:
On July 18 2013 18:09 Tobberoth wrote:
On July 18 2013 10:40 Pawsom wrote:
On July 18 2013 10:21 holdthephone wrote:
Alright, C++:

Have a text input file, want to read it into char array, but size of file is variable (could be 8 chars, 64, 512, etc...). How can I accommodate for the right amount of characters, besides simply creating an ultra huge char array?



Vectors if its C++

This would be my advice as well. You can use new (or malloc though if it's C++ I don't see why you would), but in modern C++, using vectors would probably be considered best practice.


use vector!
don't use new unless you can't not heap it.

if you are also looking to parse the files contents check out boost spirit qi! excellent parser generator library for cpp.

example parsing file into vector of chars... look how cute.

#include <fstream>
#include <vector>
#include <boost/spirit/include/qi.hpp>

namespace spirit = boost::spirit;
namespace qi = boost::spirit::qi;
std::vector<char> data;
qi::parse(spirit::istream_iterator(std::ifstream("input.txt") >> std::noskipws), spirit::istream_iterator(), *qi::char_, data)



A more generic question would be: "how do I keep a variable amount of memory reserved for X purpose". The more generic answer is: "on the heap, on the stack, or within ROM (a file on the file system, typically) [and secret option D, manually defined memory]"

You typically don't want to use the stack for unbounded amounts of memory, as it can cause a stack overflow, which could be a security hole. This is typically why you don't have unbounded recursion either.

In this case, you are trying to buffer a variable amount of memory in RAM for processing data typically stored in ROM. This would mean you will dynamically request memory from the heap. Boost's Array, std's Vector, and C's malloc library all use heap.

Typical OS behaviour states that your heap can continue to grow as long as you have pages left for the kernel to assign, so it is bounded by the amount of RAM on your system. Because the malloc library uses operating system hooks, it does not have (major) security issues like the stack does. Vector and Array are pretty good at heap management, trying to keep your data in a contiguous virtual block if possible, but calling malloc directly also has it's benefits. The keyword "new" is a wrapper around malloc that also calls the constructor for that class.

The third option would be to directly process the file in ROM without buffering the entire thing into RAM. This is a strategy used by many of the GNU utilities, as streaming data does not need a variable size buffer. Probably the fastest way, but definitely overkill in most applications.

[secret option D is just assigning a pointer to some place in memory, clearing it and using it, but why do this whenever such smart people have already build a malloc library?]


i didn't mean to imply vector does not use heap if you extrapolated that from my post (the vector itself is ofc on the stack), it usually does (does not have to). maybe i should have been more explicit instead of going for a bad pun, he he. rather to use vector instead of new for a dynamically sized array of chars, felt it was a safe bet considering the perceived context.


Wasn't meaning to correct or otherwise flame. Everything in your post was correct. I am just somewhat knowledgeable about the low-level bits, and like to drop knowledge bombs, so newbies can get a bit of context surrounding the answers to their questions. Vector is probably what he wants to use, but he may not know why its better than the alternatives... which I didn't exactly explain either...

Any sufficiently advanced technology is indistinguishable from magic
nunez
Profile Blog Joined February 2011
Norway4003 Posts
July 19 2013 00:39 GMT
#6462
On July 19 2013 09:14 RoyGBiv_13 wrote:
Show nested quote +
On July 19 2013 08:44 nunez wrote:
On July 19 2013 08:08 RoyGBiv_13 wrote:
On July 19 2013 07:40 nunez wrote:
On July 18 2013 18:09 Tobberoth wrote:
On July 18 2013 10:40 Pawsom wrote:
On July 18 2013 10:21 holdthephone wrote:
Alright, C++:

Have a text input file, want to read it into char array, but size of file is variable (could be 8 chars, 64, 512, etc...). How can I accommodate for the right amount of characters, besides simply creating an ultra huge char array?



Vectors if its C++

This would be my advice as well. You can use new (or malloc though if it's C++ I don't see why you would), but in modern C++, using vectors would probably be considered best practice.


use vector!
don't use new unless you can't not heap it.

if you are also looking to parse the files contents check out boost spirit qi! excellent parser generator library for cpp.

example parsing file into vector of chars... look how cute.

#include <fstream>
#include <vector>
#include <boost/spirit/include/qi.hpp>

namespace spirit = boost::spirit;
namespace qi = boost::spirit::qi;
std::vector<char> data;
qi::parse(spirit::istream_iterator(std::ifstream("input.txt") >> std::noskipws), spirit::istream_iterator(), *qi::char_, data)



A more generic question would be: "how do I keep a variable amount of memory reserved for X purpose". The more generic answer is: "on the heap, on the stack, or within ROM (a file on the file system, typically) [and secret option D, manually defined memory]"

You typically don't want to use the stack for unbounded amounts of memory, as it can cause a stack overflow, which could be a security hole. This is typically why you don't have unbounded recursion either.

In this case, you are trying to buffer a variable amount of memory in RAM for processing data typically stored in ROM. This would mean you will dynamically request memory from the heap. Boost's Array, std's Vector, and C's malloc library all use heap.

Typical OS behaviour states that your heap can continue to grow as long as you have pages left for the kernel to assign, so it is bounded by the amount of RAM on your system. Because the malloc library uses operating system hooks, it does not have (major) security issues like the stack does. Vector and Array are pretty good at heap management, trying to keep your data in a contiguous virtual block if possible, but calling malloc directly also has it's benefits. The keyword "new" is a wrapper around malloc that also calls the constructor for that class.

The third option would be to directly process the file in ROM without buffering the entire thing into RAM. This is a strategy used by many of the GNU utilities, as streaming data does not need a variable size buffer. Probably the fastest way, but definitely overkill in most applications.

[secret option D is just assigning a pointer to some place in memory, clearing it and using it, but why do this whenever such smart people have already build a malloc library?]


i didn't mean to imply vector does not use heap if you extrapolated that from my post (the vector itself is ofc on the stack), it usually does (does not have to). maybe i should have been more explicit instead of going for a bad pun, he he. rather to use vector instead of new for a dynamically sized array of chars, felt it was a safe bet considering the perceived context.


Wasn't meaning to correct or otherwise flame. Everything in your post was correct. I am just somewhat knowledgeable about the low-level bits, and like to drop knowledge bombs, so newbies can get a bit of context surrounding the answers to their questions. Vector is probably what he wants to use, but he may not know why its better than the alternatives... which I didn't exactly explain either...



ah ok, i am glad. the worst case scenario was that i had been unclear (or wrong) in my post, i did not mean to come off as accusing you of flaming.

in any case could you elaborate on what benefits calling malloc directly has? i am a newb in general, but specifically at the lower level bits. and also if you are aware of a good example (by good i mean as simple as possible) of a gnu util processing a file in ROM? sounds like an interesting peep. if so i will detonate the bomb while eating breakfast tomorrow in between... bites... :<
conspired against by a confederacy of dunces.
CorsairHero
Profile Joined December 2008
Canada9491 Posts
Last Edited: 2013-07-19 04:45:54
July 19 2013 04:45 GMT
#6463
For those C/Linux programmers out there? what are your go to resources for intermediate to advance level education?
© Current year.
Release
Profile Blog Joined October 2010
United States4397 Posts
July 19 2013 05:27 GMT
#6464
How important is it to learn assembly for a career in CS?

I read through most of Abductedonut's old posts and he seemed to stress it quite a bit and he seemed to be quite a sharp guy (although he definitely doesn't seem like average guy).
☺
tec27
Profile Blog Joined June 2004
United States3702 Posts
July 19 2013 05:29 GMT
#6465
On July 19 2013 14:27 Release wrote:
How important is it to learn assembly for a career in CS?

I read through most of Abductedonut's old posts and he seemed to stress it quite a bit and he seemed to be quite a sharp guy (although he definitely doesn't seem like average guy).

Very unimportant
Can you jam with the console cowboys in cyberspace?
Release
Profile Blog Joined October 2010
United States4397 Posts
July 19 2013 05:40 GMT
#6466
What about the rest of his posts, especially the first page one? It's one of the only specific paths I've seen mentioned in this thread.
☺
tec27
Profile Blog Joined June 2004
United States3702 Posts
July 19 2013 06:01 GMT
#6467
If you want to learn about assembly and assembly-level things, then do it, don't look for an excuse or permission to do so. But how useful is it professionally? Not very. There's certainly people in this thread that believe you have to start from the bottom to know how things work, but that's patently untrue. I work with a ton of talented people who have very little experience or working knowledge of assembly, yet they're some of the best people I've worked with.

I personally started out programming around age 12, and I must have tried, and failed, to learn C++ to any reasonable degree on 3 separate occasions. Then I found Delphi and was actually able to make some programs that did some interesting things, and I've never looked back since. Telling someone that they should learn assembly first is like telling a weak man he should skip everything and just try to lift 300lbs immediately. The people that do so are far more likely to get confused, frustrated, and walk away than to actually learn anything useful.

My advice? Pick some project topics that interest you, work on them in whatever language makes sense. That language will very rarely ever be C, and almost never be assembly. If you master some other languages and then decide you'd like to know more about how they work under the hood, then sure, learn C, learn assembly. By then you'll have enough varied experience that it won't be all that hard.

All of this is coming from someone who has spent a ton of time reverse engineering other software and reading assembly to do so. Do I enjoy it? Sure. Has it ever been a useful skill in my professional life? Nope.
Can you jam with the console cowboys in cyberspace?
Denar
Profile Blog Joined March 2011
France1633 Posts
July 19 2013 06:04 GMT
#6468
On July 19 2013 14:27 Release wrote:
How important is it to learn assembly for a career in CS?

I read through most of Abductedonut's old posts and he seemed to stress it quite a bit and he seemed to be quite a sharp guy (although he definitely doesn't seem like average guy).


It all depends on what you are most interested in really, CS is a very large field, and the careers that you can follow after your degree will vary a lot. Some will never use Assembly, and never consider its existence, and others will use it all the time, even nowadays. As an example, about 50% of my time at work is spent writing Assembly code.

If you love low-level programming, if everytime you use a library you wonder how things work underneath, you'll probably get a kick out of learning Assembly and getting to know your CPU better. If you don't think you'll want to work with low-level stuff, and it feels like a pain, then I don't think you need to inflinct this on yourself.
Kambing
Profile Joined May 2010
United States1176 Posts
July 19 2013 06:36 GMT
#6469
On July 19 2013 14:27 Release wrote:
How important is it to learn assembly for a career in CS?

I read through most of Abductedonut's old posts and he seemed to stress it quite a bit and he seemed to be quite a sharp guy (although he definitely doesn't seem like average guy).


How important is it to learn assembly for a career in CS? It isn't important to learn because you will be programming at the machine code level on a regular basis (you won't). It is crucial to understand because a good computer scientist should be aware of, and be able to articulate, what is happening at all levels of the computer system when a program operates.
Tobberoth
Profile Joined August 2010
Sweden6375 Posts
July 19 2013 07:02 GMT
#6470
On July 19 2013 14:27 Release wrote:
How important is it to learn assembly for a career in CS?

I read through most of Abductedonut's old posts and he seemed to stress it quite a bit and he seemed to be quite a sharp guy (although he definitely doesn't seem like average guy).

It's not important at all. However, it's extremely interesting, and I would expect most CS students to have the kind of interest in computers which assembly satisfies. Unlike all other programming languages, assembly pushes the computer architecture right in your face and really shows you how a computer works on a completely different level, even C is crazy abstraction compared to pure assembly.
Release
Profile Blog Joined October 2010
United States4397 Posts
July 19 2013 07:12 GMT
#6471
Thanks. I think I get it lol. Not necessary.
☺
adwodon
Profile Blog Joined September 2010
United Kingdom592 Posts
July 19 2013 08:05 GMT
#6472
On July 19 2013 14:27 Release wrote:
How important is it to learn assembly for a career in CS?

I read through most of Abductedonut's old posts and he seemed to stress it quite a bit and he seemed to be quite a sharp guy (although he definitely doesn't seem like average guy).


For a career in computer science? I don't know, for Software Engineering it can be quite useful though. What are CS careers anyway? I suppose cryptography?

You never need to learn assembly but it can be useful to be able to know how to step through it to ensure your symbols are lining up properly and to figure out exactly whats going on in some highly obfuscated code etc

It's usually a last resort though and stepping through something isn't that hard if you have a reference book.

Basically I'd say it may be worth reading a bit about it in your spare time but unless you're facing a situation where its required I wouldn't worry about it, unless you plan on writing compilers etc its probably more a hindrance than a help to dedicate serious time to understanding it. That being said if you do I'd go for x86-64, seems pointless learning x86-32 nowadays.
CorsairHero
Profile Joined December 2008
Canada9491 Posts
July 19 2013 11:13 GMT
#6473
if you want to analyze viruses/malware, assembly (x86) is a must.
© Current year.
tofucake
Profile Blog Joined October 2009
Hyrule19203 Posts
July 19 2013 12:19 GMT
#6474
Assembly is nice to learn after you've been programming for a while. It's tied to hardware and will give you a better idea of how programming actually works. There are very few cases where it's actually required.
Liquipediaasante sana squash banana
IreScath
Profile Joined May 2009
Canada521 Posts
July 19 2013 15:26 GMT
#6475
So I'm having a wierd issue with a Perl script, but it might not be a Perl problem per say....

Essentially I have some testing automated for certain apps... before my perl script runs said app, it creates/alters some registry keys.

However if the keys already exist as is in the registry... Creating them is causing some of the values to become "Invalid" in the registry... :S

relevant code:
+ Show Spoiler +

use Win32::Registry;

... other code ...

my $p="SOFTWARE";
$main::HKEY_CURRENT_USER->Open($p, $CurrVer);
$CurrVer->Create("APPCOMPANY", $F1);
$F1->Create("APPNAME", $F2);
$F2->Create("Preferences", $F3);
$F2->Create("Browser", $keyme3);
$F2->Create("LastSelection", $keyme2);
$F3->Create("General", $keyme1);
$F3->Create("OpenCL", $keyme4);

$keyme1->SetValueEx("DoCheckForUpdatesOnStartup", 0, REG_SZ, "False");
$keyme2->SetValueEx("active", 0, REG_SZ, "FileSystem");
$keyme3->SetValueEx("dir", 0, REG_SZ, "path\path\path");
$keyme3->SetValueEx("lastselectedpath", 0, REG_SZ, "path/path/path");
$keyme4->SetValueEx("Enabled", 0, REG_SZ, "true");
$keyme4->SetValueEx("CLUtilization", 0, REG_DWORD, "3");



It's just the active key that messes up and goes invalid every other time its run.... I can't figure it out... Can any perl experts figure it out?... or maybe there is a way to check if the key is already there before creating it?..Not sure how to do that.
IreScath
RoyGBiv_13
Profile Blog Joined August 2010
United States1275 Posts
July 19 2013 16:54 GMT
#6476
On July 19 2013 09:39 nunez wrote:
Show nested quote +
On July 19 2013 09:14 RoyGBiv_13 wrote:
On July 19 2013 08:44 nunez wrote:
On July 19 2013 08:08 RoyGBiv_13 wrote:
On July 19 2013 07:40 nunez wrote:
On July 18 2013 18:09 Tobberoth wrote:
On July 18 2013 10:40 Pawsom wrote:
On July 18 2013 10:21 holdthephone wrote:
Alright, C++:

Have a text input file, want to read it into char array, but size of file is variable (could be 8 chars, 64, 512, etc...). How can I accommodate for the right amount of characters, besides simply creating an ultra huge char array?



Vectors if its C++

This would be my advice as well. You can use new (or malloc though if it's C++ I don't see why you would), but in modern C++, using vectors would probably be considered best practice.


use vector!
don't use new unless you can't not heap it.

if you are also looking to parse the files contents check out boost spirit qi! excellent parser generator library for cpp.

example parsing file into vector of chars... look how cute.

#include <fstream>
#include <vector>
#include <boost/spirit/include/qi.hpp>

namespace spirit = boost::spirit;
namespace qi = boost::spirit::qi;
std::vector<char> data;
qi::parse(spirit::istream_iterator(std::ifstream("input.txt") >> std::noskipws), spirit::istream_iterator(), *qi::char_, data)



A more generic question would be: "how do I keep a variable amount of memory reserved for X purpose". The more generic answer is: "on the heap, on the stack, or within ROM (a file on the file system, typically) [and secret option D, manually defined memory]"

You typically don't want to use the stack for unbounded amounts of memory, as it can cause a stack overflow, which could be a security hole. This is typically why you don't have unbounded recursion either.

In this case, you are trying to buffer a variable amount of memory in RAM for processing data typically stored in ROM. This would mean you will dynamically request memory from the heap. Boost's Array, std's Vector, and C's malloc library all use heap.

Typical OS behaviour states that your heap can continue to grow as long as you have pages left for the kernel to assign, so it is bounded by the amount of RAM on your system. Because the malloc library uses operating system hooks, it does not have (major) security issues like the stack does. Vector and Array are pretty good at heap management, trying to keep your data in a contiguous virtual block if possible, but calling malloc directly also has it's benefits. The keyword "new" is a wrapper around malloc that also calls the constructor for that class.

The third option would be to directly process the file in ROM without buffering the entire thing into RAM. This is a strategy used by many of the GNU utilities, as streaming data does not need a variable size buffer. Probably the fastest way, but definitely overkill in most applications.

[secret option D is just assigning a pointer to some place in memory, clearing it and using it, but why do this whenever such smart people have already build a malloc library?]


i didn't mean to imply vector does not use heap if you extrapolated that from my post (the vector itself is ofc on the stack), it usually does (does not have to). maybe i should have been more explicit instead of going for a bad pun, he he. rather to use vector instead of new for a dynamically sized array of chars, felt it was a safe bet considering the perceived context.


Wasn't meaning to correct or otherwise flame. Everything in your post was correct. I am just somewhat knowledgeable about the low-level bits, and like to drop knowledge bombs, so newbies can get a bit of context surrounding the answers to their questions. Vector is probably what he wants to use, but he may not know why its better than the alternatives... which I didn't exactly explain either...



ah ok, i am glad. the worst case scenario was that i had been unclear (or wrong) in my post, i did not mean to come off as accusing you of flaming.

in any case could you elaborate on what benefits calling malloc directly has? i am a newb in general, but specifically at the lower level bits. and also if you are aware of a good example (by good i mean as simple as possible) of a gnu util processing a file in ROM? sounds like an interesting peep. if so i will detonate the bomb while eating breakfast tomorrow in between... bites... :<


Here is the git source tree for "sed", the GNU stream editor. Scanning through the code, you'll want to look for process_files function under the execute.c, this is where the magic happens. In the early stage of processing the files, it buffers only one line at a time, malloc'ing 50 bytes for processing as per "INITIAL_BUFFER_SIZE". Later when writing back to the file, it has a buffer of 8kB, defined as FREAD_BUFFER_SIZE in order to quickly scan through a file to find where it is supposed to append each change in the file it is supposed to make. Note that this is not strictly for file streams, and is meant for any generic stream (pipe, socket, or file pointer).

You can use malloc directly for a lot of very clever memory management techniques. For example, In game design, you know that the maximum buffer size you will need, and are worried most about the worst case, so malloc'ing the entire size at the beginning of the program could save you time during a critical loop later.

My personal favorite clever use of malloc I saw a customer of mine use when doing some network optimizations. They were building a crypto stream cipher, and needed a large amount of unbounded variable memory to work on (>40MB), but couldn't pay the CPU tax when the time was needed to run the cipher. Sometimes, the network requested faster than the cipher, but sometimes slower. They malloc'd a large space near the beginning of the board initialization for the initial heap, and as the cipher got to a threshold limit in the heap, it would add another page onto the heap during a brief moment the CPU was not running the cipher because it was accessing the network peripheral on the chip. They found that where they were calling malloc() from, even within the same loop, had a large performance impact, because there is only one task allowed "inside" the kernel at a time, and adding a page to the heap requires asking the kernel for the page. When the cipher was running, it was inside the kernel, as it had to access physical registers directly.
Any sufficiently advanced technology is indistinguishable from magic
HardlyNever
Profile Blog Joined July 2011
United States1258 Posts
Last Edited: 2013-07-19 17:45:00
July 19 2013 17:44 GMT
#6477
On July 18 2013 11:46 Rotodyne wrote:
Show nested quote +
On July 17 2013 06:30 HardlyNever wrote:
Anyone have experience with this JQuery plugin ?

http://jqueryvalidation.org/

I'm having trouble getting it to work on my form. Or anyone recommend another jquery plugin to validate my forms (they don't have to be too robust).


I have used that one before and it seemed to work well. If you post your code or PM me I could take a look.


Thanks. I'm trying to get it so that the user has to select a drop down option in the "serviceArea" drop down (so the value can't be "Select..."). I'm also trying to get it to stay on the page (not go to my form action php page) after submission. I know I can use php header for this, but I'm sure there is a way to do it with javascript, I just don't know how.

Relevant html/js + Show Spoiler +
<form id="myform" action="php/suggestionFunc.php" method="post" title="suggestion">

<fieldset>
<legend>Service Area</span></legend>

<div class="option">
<select name="serviceArea">
<option value="select" selected />Select...</option>
<option value="Website" />Website</option>
<option value="Reference" />Reference</option>
<option value="Circulation" />Circulation</option>
<option value="Collection" />Collection</option>
<option value="Instruction" />Instruction</option>
</select>
</div>

</fieldset>

<fieldset>
<legend>Comment</legend>
<div>


<div class="fm-req">
<label for="comments">Comments: </label>
<textarea rows="5" cols="50" name="comments" id="comments" placeholder="enter comments" required ></textarea>
</div>

</div>
</fieldset>



<fieldset>
<legend>Contact Information:</legend>

<p>(Optional, If you would like a response)</p>
<br>
<div class="fm-opt">
<label for=name>Name:</label>
<input type="text" size="50" name="name" id="name" placeholder="Optional" />
</div>

<div class="fm-opt">
<label for=email>E-Mail:</label>
<input type="email" size="50" name="email" id="email" placeholder="Optional" />
</div>

<div class="fm-opt">
<label for=phone>Phone:</label>
<input type="text" size="50" name="phone" id="phone" placeholder="Optional" />
</div>

<div class="radio">
<ul>
<li><input class="radio" type="radio" name="status" value="Faculty" checked /> <label>Faculty</label></li>
<li><input class="radio" type="radio" name="status" value="Staff" /> <label>Staff</label></li>
<li><input class="radio" type="radio" name="status" value="Student" /> <label>Student</label></li>
<li><input class="radio" type="radio" name="status" value="Other" /> <label>Other</label></li>
</ul>
</div>
</fieldset>
<div id="fm-submit">
<input id="submit" type="submit" name="Submit" value="Submit" />
<input id="reset" type="reset" name="Reset" value="Reset" />
</div>

</form>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js"></script>
<script src="js/jquery.validate.js"></script>
<script>
$("#myform").validate();
</script>



Thanks for the help.
Out there, the Kid learned to fend for himself. Learned to build. Learned to break.
Yoshi-
Profile Joined October 2008
Germany10227 Posts
July 19 2013 17:54 GMT
#6478
@Hardlynever: your code works perfectly fine for me
You should check maybe the JS console if it gives you any error
HardlyNever
Profile Blog Joined July 2011
United States1258 Posts
July 19 2013 18:03 GMT
#6479
The form should work fine. It's the validator jquery plugin that I don't really know how to configure.
Out there, the Kid learned to fend for himself. Learned to build. Learned to break.
Yoshi-
Profile Joined October 2008
Germany10227 Posts
Last Edited: 2013-07-19 18:36:26
July 19 2013 18:31 GMT
#6480
Ahh sorry I missed your first sentence

Here this stackoverflow post gives you a way of doing this:
http://stackoverflow.com/questions/2901125/jquery-validate-required-select

Dunno if that plugin has a native function for that, the documentation is horrendus
Prev 1 322 323 324 325 326 1032 Next
Please log in or register to reply.
Live Events Refresh
WardiTV Map Contest Tou…
11:00
Group D
WardiTV408
TKL 126
IndyStarCraft 104
Rex62
3DClanTV 48
Liquipedia
Sparkling Tuna Cup
10:00
Weekly #128 (TLMC 22 Edition)
ByuN vs HonMonOLIVE!
CranKy Ducklings134
herO (SOOP)36
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
TKL 126
IndyStarCraft 104
Rex 62
MindelVK 45
herO (SOOP) 36
StarCraft: Brood War
Britney 23563
Calm 4539
Horang2 1500
ToSsGirL 614
Larva 434
EffOrt 354
Zeus 344
NaDa 248
BeSt 245
firebathero 213
[ Show more ]
Last 165
Killer 157
ZerO 144
Soma 130
PianO 102
Hyun 89
Rush 82
Sharp 60
ggaemo 58
Pusan 55
Nal_rA 42
[sc1f]eonzerg 41
sSak 39
Mind 39
Soulkey 32
Barracks 32
yabsab 22
soO 15
Sea.KH 15
Noble 15
SilentControl 15
IntoTheRainbow 14
Shinee 13
Movie 12
Hm[arnc] 12
sorry 6
Dota 2
XaKoH 648
Counter-Strike
zeus1202
x6flipin341
edward150
Super Smash Bros
Mew2King162
Heroes of the Storm
Khaldor260
Other Games
singsing1475
B2W.Neo1039
Pyrionflax164
DeMusliM157
ZerO(Twitch)14
Organizations
Dota 2
PGL Dota 2 - Main Stream7480
PGL Dota 2 - Secondary Stream3394
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 15 non-featured ]
StarCraft 2
• Adnapsc2 16
• CranKy Ducklings SOOP5
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• FirePhoenix2
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Jankos2251
• TFBlade824
Upcoming Events
Ladder Legends
3h 39m
IPSL
4h 39m
JDConan vs TBD
Aegong vs rasowy
BSL
7h 39m
StRyKeR vs rasowy
Artosis vs Aether
JDConan vs OyAji
Hawk vs izu
CranKy Ducklings
12h 39m
Replay Cast
21h 39m
Wardi Open
22h 39m
Afreeca Starleague
22h 39m
Bisu vs Ample
Jaedong vs Flash
Monday Night Weeklies
1d 4h
RSL Revival
1d 14h
Afreeca Starleague
1d 22h
Barracks vs Leta
Royal vs Light
[ Show More ]
WardiTV Map Contest Tou…
1d 23h
RSL Revival
2 days
Replay Cast
3 days
The PondCast
3 days
KCM Race Survival
3 days
WardiTV Map Contest Tou…
3 days
Replay Cast
4 days
Escore
4 days
RSL Revival
5 days
WardiTV Map Contest Tou…
5 days
Ladder Legends
6 days
uThermal 2v2 Circuit
6 days
BSL
6 days
Sparkling Tuna Cup
6 days
WardiTV Map Contest Tou…
6 days
Liquipedia Results

Completed

Escore Tournament S2: W3
RSL Revival: Season 4
NationLESS Cup

Ongoing

BSL Season 22
ASL Season 21
CSL 2026 SPRING (S20)
IPSL Spring 2026
KCM Race Survival 2026 Season 2
StarCraft2 Community Team League 2026 Spring
WardiTV TLMC #16
Nations Cup 2026
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026
IEM Kraków 2026

Upcoming

Escore Tournament S2: W4
Acropolis #4
BSL 22 Non-Korean Championship
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
2026 GSL S2
RSL Revival: Season 5
2026 GSL S1
XSE Pro League 2026
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
IEM Atlanta 2026
Asian Champions League 2026
PGL Astana 2026
BLAST Rivals Spring 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.