Project help, trying to Create/Delete from access database

Ok, what did you learn in your class, servlets or JSP, or both? If both, does it matter which method you use?
 
Yup, I'm using servlets, jsps :) and of course java models

So far Ive done the following: The user first sees a page that says "TO begin, click!" and the user clicks" The servlet makes a query and shows a view of the Actor's table. Where I then have two forms one for add, the other for delete.

That's where Im at now.

Well, I'm pretty much done. I need help adding JS validation for dates. Is it possible to put two functions to one onsubmit?

Anyway, any help with this would be cool.
 
You can make two function calls, consider this page here. This is a site we are about to finish up at my company. The form uses some client side validation I wrote. It works pretty well.
http://www.tritg.com/teton/contact.php

Here is the associated script separated from the page.

Code:
function validateForm(obj){

var me = this;

me.isValid = true;

var firstEmail;

for(i=0;i<obj.elements.length;i++){

var currentInput = obj.elements[i];

 var outputName = currentInput.id + "opt";

 switch(obj.elements[i].name){

  case "uname":

   if(currentInput.value.length == 0){

      document.getElementById(outputName).style.visibility="visible";

	  document.getElementById(outputName).style.color="red";

	  document.getElementById(outputName).style.display="block";

	  document.getElementById(outputName).innerHTML = "Please enter your name.";

	  me.isValid = false;

   }else{

      document.getElementById(outputName).style.visibility="hidden";

	  document.getElementById(outputName).style.display="none";

	  document.getElementById(outputName).style.color="";

	  document.getElementById(outputName).innerHTML = "";

   }//end of if

   break;

  case "phoneNum":

   var phoneExpression = /^[0-9]{10}$/;

   if(currentInput.value.match(phoneExpression) && currentInput.value.length > 0){

      document.getElementById(outputName).style.visibility="hidden";

	  document.getElementById(outputName).style.display="none";

      document.getElementById(outputName).style.color="";

	  document.getElementById(outputName).innerHTML = "";

   }else if(currentInput.value.length > 0 && !currentInput.value.match(phoneExpression)) {

      document.getElementById(outputName).style.visibility="visible";

	  document.getElementById(outputName).style.color="red";

	  document.getElementById(outputName).style.display="block";

	  document.getElementById(outputName).innerHTML = "Please enter a valid phone number.";

	  me.isValid = false;

	} else {

	  document.getElementById(outputName).style.visibility="hidden";

	  document.getElementById(outputName).style.display="none";

	  document.getElementById(outputName).style.color="";

	  document.getElementById(outputName).innerHTML = "";

	} // end if/else

   break;

  case "email":

   var emailExpression = /([a-zA-z0-9\.\-]+)@([a-zA-Z0-9\.\-]+)\.([a-zA-Z]{2,3})/;

   var firstEmail = currentInput.value;

   if(currentInput.value.length == 0){

      document.getElementById(outputName).style.visibility="visible";

	  document.getElementById(outputName).style.color="red";

	  document.getElementById(outputName).style.display="block";

	  document.getElementById(outputName).innerHTML="Please enter your e-mail address.";

	  me.isValid = false;

   }else if(!currentInput.value.match(emailExpression)){

      document.getElementById(outputName).style.visibility="visible";

	  document.getElementById(outputName).style.color="red";

	  document.getElementById(outputName).style.display="block";

	  document.getElementById(outputName).innerHTML="Please check your e-mail address to make sure it is valid.";

	  me.isValid = false;

   }else if(currentInput.value.match(emailExpression)){

      document.getElementById(outputName).style.visibility="hidden";

	  document.getElementById(outputName).style.display="none";

      document.getElementById(outputName).style.color="";

	  document.getElementById(outputName).innerHTML="";

   }//end of if

   break;

  case "email2":

  //alert(firstEmail);

  //alert(currentInput.value);

   if(currentInput.value != firstEmail){

      document.getElementById(outputName).style.visibility="visible";

      document.getElementById(outputName).style.color="red";

	  document.getElementById(outputName).style.display="block";

	  document.getElementById(outputName).innerHTML="Please make sure your e-mail addresses match.";

	  me.isValid = false;

   }else{

      document.getElementById(outputName).style.visibility="hidden";

	  document.getElementById(outputName).style.display="none";

      document.getElementById(outputName).style.color="";

	  document.getElementById(outputName).innerHTML="";

   }

   break;

  /*case "content1":

   if(currentInput.value.length == 0){

      document.getElementById(outputName).style.visibility="visible";

   	  document.getElementById(outputName).style.color="red";

	  document.getElementById(outputName).style.display="block";

	  document.getElementById(outputName).innerHTML="Input your question and/or comment.";

	  me.isValid = false;

   }else{

      document.getElementById(outputName).style.visibility="hidden";

	  document.getElementById(outputName).style.display="none";

      document.getElementById(outputName).style.color="";

	  document.getElementById(outputName).innerHTML = "";

   } //end of if

  break;*/

 }//end of switch

 }//end of for loop

 if (!me.isValid) {

   document.getElementById("userError").style.visibility = "visible";

   document.getElementById("userError").innerHTML = "There were some problems submitting your information.  Please check all of the highlighted items and try again.";

 } else {

   document.getElementById("userError").style.visibility = "hidden";

   document.getElementById("userError").innerHTML = "";

 } // end if/else

 return me.isValid;

}//end of function validateForm



function clearErrors() {

  document.getElementById("userError").style.visibility = "hidden";

  for(i=0;i<document.getElementById("formError").childNodes.length;i++) {

    document.getElementById("formError").childNodes[i].innerHTML = "";

  } // end for loop

} // end function clearErrors

The form isn't running yet, so you can play with submitting it without worrying about submitting info if you want, to test what the script does.

Hope that helps.
 
You can make two function calls, consider this page here. This is a site we are about to finish up at my company. The form uses some client side validation I wrote. It works pretty well.
http://www.tritg.com/teton/contact.php

Here is the associated script separated from the page.

Code:
function validateForm(obj){

var me = this;

me.isValid = true;

var firstEmail;

for(i=0;i<obj.elements.length;i++){

var currentInput = obj.elements[i];

 var outputName = currentInput.id + "opt";

 switch(obj.elements[i].name){

  case "uname":

   if(currentInput.value.length == 0){

      document.getElementById(outputName).style.visibility="visible";

	  document.getElementById(outputName).style.color="red";

	  document.getElementById(outputName).style.display="block";

	  document.getElementById(outputName).innerHTML = "Please enter your name.";

	  me.isValid = false;

   }else{

      document.getElementById(outputName).style.visibility="hidden";

	  document.getElementById(outputName).style.display="none";

	  document.getElementById(outputName).style.color="";

	  document.getElementById(outputName).innerHTML = "";

   }//end of if

   break;

  case "phoneNum":

   var phoneExpression = /^[0-9]{10}$/;

   if(currentInput.value.match(phoneExpression) && currentInput.value.length > 0){

      document.getElementById(outputName).style.visibility="hidden";

	  document.getElementById(outputName).style.display="none";

      document.getElementById(outputName).style.color="";

	  document.getElementById(outputName).innerHTML = "";

   }else if(currentInput.value.length > 0 && !currentInput.value.match(phoneExpression)) {

      document.getElementById(outputName).style.visibility="visible";

	  document.getElementById(outputName).style.color="red";

	  document.getElementById(outputName).style.display="block";

	  document.getElementById(outputName).innerHTML = "Please enter a valid phone number.";

	  me.isValid = false;

	} else {

	  document.getElementById(outputName).style.visibility="hidden";

	  document.getElementById(outputName).style.display="none";

	  document.getElementById(outputName).style.color="";

	  document.getElementById(outputName).innerHTML = "";

	} // end if/else

   break;

  case "email":

   var emailExpression = /([a-zA-z0-9\.\-]+)@([a-zA-Z0-9\.\-]+)\.([a-zA-Z]{2,3})/;

   var firstEmail = currentInput.value;

   if(currentInput.value.length == 0){

      document.getElementById(outputName).style.visibility="visible";

	  document.getElementById(outputName).style.color="red";

	  document.getElementById(outputName).style.display="block";

	  document.getElementById(outputName).innerHTML="Please enter your e-mail address.";

	  me.isValid = false;

   }else if(!currentInput.value.match(emailExpression)){

      document.getElementById(outputName).style.visibility="visible";

	  document.getElementById(outputName).style.color="red";

	  document.getElementById(outputName).style.display="block";

	  document.getElementById(outputName).innerHTML="Please check your e-mail address to make sure it is valid.";

	  me.isValid = false;

   }else if(currentInput.value.match(emailExpression)){

      document.getElementById(outputName).style.visibility="hidden";

	  document.getElementById(outputName).style.display="none";

      document.getElementById(outputName).style.color="";

	  document.getElementById(outputName).innerHTML="";

   }//end of if

   break;

  case "email2":

  //alert(firstEmail);

  //alert(currentInput.value);

   if(currentInput.value != firstEmail){

      document.getElementById(outputName).style.visibility="visible";

      document.getElementById(outputName).style.color="red";

	  document.getElementById(outputName).style.display="block";

	  document.getElementById(outputName).innerHTML="Please make sure your e-mail addresses match.";

	  me.isValid = false;

   }else{

      document.getElementById(outputName).style.visibility="hidden";

	  document.getElementById(outputName).style.display="none";

      document.getElementById(outputName).style.color="";

	  document.getElementById(outputName).innerHTML="";

   }

   break;

  /*case "content1":

   if(currentInput.value.length == 0){

      document.getElementById(outputName).style.visibility="visible";

   	  document.getElementById(outputName).style.color="red";

	  document.getElementById(outputName).style.display="block";

	  document.getElementById(outputName).innerHTML="Input your question and/or comment.";

	  me.isValid = false;

   }else{

      document.getElementById(outputName).style.visibility="hidden";

	  document.getElementById(outputName).style.display="none";

      document.getElementById(outputName).style.color="";

	  document.getElementById(outputName).innerHTML = "";

   } //end of if

  break;*/

 }//end of switch

 }//end of for loop

 if (!me.isValid) {

   document.getElementById("userError").style.visibility = "visible";

   document.getElementById("userError").innerHTML = "There were some problems submitting your information.  Please check all of the highlighted items and try again.";

 } else {

   document.getElementById("userError").style.visibility = "hidden";

   document.getElementById("userError").innerHTML = "";

 } // end if/else

 return me.isValid;

}//end of function validateForm



function clearErrors() {

  document.getElementById("userError").style.visibility = "hidden";

  for(i=0;i<document.getElementById("formError").childNodes.length;i++) {

    document.getElementById("formError").childNodes[i].innerHTML = "";

  } // end for loop

} // end function clearErrors

The form isn't running yet, so you can play with submitting it without worrying about submitting info if you want, to test what the script does.

Hope that helps.

What does this script do?
 
The Code Project .... Generally, one of the first steps when you are trying to work with ..... Maybe enybody know how to join MS Access database and MS SQL 2005 ... How to create a MSSQL ( or MSSQL2005 Express) database using ADO ( Not ADO. ... how to save,search,delete and edit a record into the database using ...
 
Back
Top Bottom