title: Is it better practice to have 2 functions, or 1 complex function?
body: <p>I'm curious as to what is considered better practice in the programming community.</p>
  
  <p>On submit, a function is called, where some validation is done, and then a post is made through AJAX. I was considering having a function handle them both. I would change all element IDs to be the same, with only the difference of an incrementing number (e.g. txt1, txt2 / txt1Cnt, txt2Cnt / txt1Lbl, txt2Lbl, etc...)</p>
  
  <p>Then I'd add loops and conditional statements to properly handle each form. This sounds like the fun way, which is why I wanted to do it, but now I'm thinking that maybe it would not be considered very efficient, since I wouldn't need to differentiate all the different elements if I just had 2 functions. Especially because the forms are not identical.</p>
  
  <p>So, my question is, is there a rule of thumb when it comes to this sort of thing? Is it better to have less functions, or less complexity?</p>
  
  <p>Thanks for your time.</p>