Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 05-04-2009, 01:16 PM   #11
In Runtime
 
Daeva's Avatar
 
Join Date: Dec 2005
Posts: 407
Send a message via AIM to Daeva Send a message via MSN to Daeva Send a message via Yahoo to Daeva
Default Re: 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.
__________________

__________________
**Official Self-proclaimed glorified excessive (insert additional adjectives here) post editor/modifier.
Edit = Best feature ever
http://www.twitter.com/xDaevax
Daeva is offline   Reply With Quote
Old 05-04-2009, 05:15 PM   #12
In Runtime
 
akira282's Avatar
 
Join Date: Mar 2009
Posts: 172
Default Re: Project help, trying to Create/Delete from access database

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?
__________________

__________________
[CPU] Intel Core i7 920 @ 2.66 [MOBO] ASUS P6T Deluxe V2 [GPU] EVGA GeForce GTX 260 SCE 896MB 620MHz/216 core [RAM] G.Skill 6GB DDR3 1333 7-7-7-18 [HD] WD Cav Black 640GB 7200RPM [DRIVE] Samsung DVD/CD burner [PSU] OCZ 700w [MONITOR] LG 1080p, 1920x1080 23" 2ms GTG Widescreen LCD [KEYBOARD] Saitek Eclipse Blue [CASE] Antec 902[OS] Windows Vista 64bit Home Prem.
akira282 is offline   Reply With Quote
Old 05-04-2009, 05:44 PM   #13
In Runtime
 
Daeva's Avatar
 
Join Date: Dec 2005
Posts: 407
Send a message via AIM to Daeva Send a message via MSN to Daeva Send a message via Yahoo to Daeva
Default Re: Project help, trying to Create/Delete from access database

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.
__________________
**Official Self-proclaimed glorified excessive (insert additional adjectives here) post editor/modifier.
Edit = Best feature ever
http://www.twitter.com/xDaevax
Daeva is offline   Reply With Quote
Old 05-04-2009, 11:36 PM   #14
In Runtime
 
akira282's Avatar
 
Join Date: Mar 2009
Posts: 172
Default Re: Project help, trying to Create/Delete from access database

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.
__________________
[CPU] Intel Core i7 920 @ 2.66 [MOBO] ASUS P6T Deluxe V2 [GPU] EVGA GeForce GTX 260 SCE 896MB 620MHz/216 core [RAM] G.Skill 6GB DDR3 1333 7-7-7-18 [HD] WD Cav Black 640GB 7200RPM [DRIVE] Samsung DVD/CD burner [PSU] OCZ 700w [MONITOR] LG 1080p, 1920x1080 23" 2ms GTG Widescreen LCD [KEYBOARD] Saitek Eclipse Blue [CASE] Antec 902[OS] Windows Vista 64bit Home Prem.
akira282 is offline   Reply With Quote
Old 05-05-2009, 07:18 PM   #15
In Runtime
 
Daeva's Avatar
 
Join Date: Dec 2005
Posts: 407
Send a message via AIM to Daeva Send a message via MSN to Daeva Send a message via Yahoo to Daeva
Default Re: Project help, trying to Create/Delete from access database

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...
__________________

__________________
**Official Self-proclaimed glorified excessive (insert additional adjectives here) post editor/modifier.
Edit = Best feature ever
http://www.twitter.com/xDaevax
Daeva is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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



All times are GMT -5. The time now is 09:14 AM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0