Project help, trying to Create/Delete from access database

Sorry, I probably should have clarified more.

That script (when the user clicks the submit button), runs through all of the input elements in the form.

It looks for specific input elements (text,textarea,etc...). If it finds one of these, it checks the name of the element (indicating which type of validation should be performed on it, whether it is required, or needs a regular expression validation, or two fields need to match, etc...) and performs the validation.

If the validation passes, it does nothing.

Initially a boolean value indicating whether the form is valid or not is set to true. The ONLY time this value is changed is if one of the validations fails. Upon a failure, it makes a note of which field failed and why, then displays a summary to the user explaining why it failed. On the textarea, it also track the number of characters remaining in the field.

Both the phone number and e-mail address are validated to ensure that bogus information is not entered into the field, thus improving the integrity of the data sent to the end-user.

Let me know if you have any other questions.
 
Yea, I'd like to know how to do JS date validation, any ideas. I found a few scripts online, however I'm not sure how to get them to work. Also, is it possible to create a generic wrapper function to hold two validation functions? Because I think it's only possible to have onsubmit="asdfasd" once right? Meaning only one action/method right?
 
well, what type of validation do you want to do on the date?

And that code I have is sort of like a wrapper, encompassing all of the validation in a single function call.

Its also important to note that the function in onsubmit must return true or false. If it returns false, it will not submit. If it returns true, it will post back to the JSP.

So an example might be:
Code:
<script type="text/javascript">
<!--
  function validateMe(obj) {
    for(i=0;i<obj.elements.length;i++) { // go through all of the inputs in the form
      if (obj.elements[i].type=="text") { // if it's a text box
       validateTextBox(obj.elements[i]); //call the validateTextBox function
      } // end if
    } // end for loop
  } // end function
  function validateTextBox(obj) {
    if (obj.value.length > 0) {
       // do something because they entered text
    } else {
       // do something because they left it blank
    } // end if/else
  } // end function validateText
//-->
</script>
<form onsubmit="return validateMe(this);">
</form>

Let me know if you have any other questions.
 
Appreciate all the help:

I want to do this validation: mm/dd/YYYY

No worries mate, I figured it out. Thanks for your time though.

Much appreciated.
 
Okay. You can get pretty crazy with regular expressions, but regex is the way you want to go for the date.

I use this website a lot to create my own regular expressions:
http://public.kvalley.com/regex/regex.asp

It gives you a field to enter in a string to validate, and also a textbox to enter the regular expression to validate it against.
It also gives you a regex cheatsheet.

Here is an example about how to create a regular expression in javascript:
Code:
var myRegex = new RegExp("e");
if(myRegex.test("Hello")) {
  alert("e was found in the word Hello");
  // in your case, validate the text they input vs your date regular expression, whatever it is
} else {
  alert("e was not found in the word Hello");
} // end if/else
This is a very simple example, but you should get the idea.

Here is a link to a website with various date regular expressions if you don't want to make your own.
http://www.regular-expressions.info/dates.html

Hope that is helpful.

*EDIT: Just saw that you got it already. Heh...
 
Back
Top Bottom