Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Function Validation

    Hi, this is my function which im trying to validate from a form to check if the input box's are empty or not. Does anybody know what im doing wrong?. Also how can i call this function(button) from an external file. any suggestions appreciated.



    Code:
    function process(form) {
    //do the date
    var now = new Date();
    fixDate(now);
    now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
    
    	var num1 = document.story.one.value;
    	var num2 = document.story.two.value;
    	var num3 = document.story.three.value;
    	var num4 = document.story.four.value; 
    	var num5 = document.story.five.value; 
    	var num6 = document.story.six.value; 
    	var num7 = document.story.seven.value;
    	var num8 = document.story.eight.value;
    	var num9 = document.story.nine.value;
    	var num10 = document.story.ten.value;
    	
    	if (document.story.one.value == ""){
    		alert ("Please give a name, e.g John, Peter...");
    		document.story.one.focus();
    		return false;
     	}	
    	if (num2 == ""){
     		alert ("Please give a place, e.g garden, park...");
     		document.story.two.focus();
     		return false;}
    	
    	if (num3 == ""){
     		alert ("Please enter a feeling, e.g tired, exausted... ");
     		document.story.three.focus();
     		return false;}
    		
    	if (num4 == ""){
    		alert ("Please enter an exercise, e.g sowing, planting... ");
     		document.story.four.focus();
     	 	return false;}
     
        if (num5 == ""){
    		alert ("Please enter a , e.g ");
     		document.story.five.focus();
     	 	return false;}
     
        if (num6 == ""){
    		alert ("Please enter an action, e.g dig, plant...");
     		document.story.six.focus();
     	 	return false;}	
    
        if (num7 == ""){
    		alert ("Please enter a second name, Alex, Paul...");
     		document.story.seven.focus();
     	 	return false;}
    		
    	if (num8 == ""){
    		alert ("Please enter a second exercise, e.g cleaning, watering");
     		document.story.eight.focus();
     	 	return false;}
    		
    	if (num9 == ""){
    		alert ("Please enter an emotion, e.g determined, dogged");
     		document.story.nine.focus();
     	 	return false;}
    		
    	if (num10 == ""){
    		alert ("Please enter a statement, e.g comfront, challenge");
     		document.story.ten.focus();
     	 	return false;}
    		
    		else{
    	
    //now save data
    setCookie("Person",document.story.one.value, now);
    setCookie("Place",document.story.two.value, now);
    setCookie("Descriptive",document.story.three.value, now);
    setCookie("Thing",document.story.four.value, now);
    setCookie("Status",document.story.five.value, now);
    setCookie("Action",document.story.six.value, now);
    setCookie("Person2",document.story.seven.value, now);
    setCookie("Thing2",document.story.eight.value, now);
    setCookie("Emotion",document.story.nine.value, now);
    setCookie("Statement",document.story.ten.value, now);
    
    alert(document.cookie);
    }
    Last edited by liorean; 06-10-2004 at 07:44 PM. Reason: [code]ified

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What error, errors or lack of errors are you seeing? How are you calling the validation function?
    Check out the Forum Search. It's the short path to getting great results from this forum.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •