JavaScript/JQuery Form Validation Help

Hi everyone -

I’m tasked to build validation for an HTML form using JavaScript. I’ve never actually done JavaScript form validation so this is a pretty new area for me and the tutorials I’ve found have been a bit helpful but I haven’t found scenarios for these types of validation:

  • Make sure the first name and last name fields aren’t empty. Before sending the names to the server, process them so that they would have the first capital letter and all the remaining letters are small.
  • Check that the State field contains two capital letters.
  • Make sure ZIP code field is positive number.
  • Check that a value is selected in a list of check boxes.
  • Check for a valid date in the date field.
  • Check that something is selected in the radio button selection.

Sorry for all of the unique scenarios, going crazy trying to figure these out. If any one can recommend how to go about creating the above validations or useful spots to check I’d appreciate it.

(The university is teaching extremely dates and poor habits for JavaScript validation I’ve been told so I’m hoping to get a better understanding…)

Thanks guys

Homework assignment?

There are plenty of validation tutorials on the webnet: Google search. So it doesn’t sound as if you’ve given it all you’ve got. For the last three, narrow the search down by adding the applicable search term (checkbox, date, radio). For the first two, you would need a [URL=“”]regular expression (regex). For the third, you could use either a regex or the Javascript function [URL=“”]isNaN (is Not a Number). Although for a positive number you would best use a regex.

Yes, this is an assignment. I’ll try searching around Google some more, I completely agree I found tons of great tutorials but just not for all of the cases I was looking for but that’s probably due to poor searching.

Appreciate the reply Frank!

Got everything figured out, this can be closed :slight_smile: