stevoreeno1 Posted May 24, 2003 Posted May 24, 2003 Does the field validation preference work on the web? I have a database hosted in which users are required to fill in data on certain fields that have validations on them i.e. "not empty", "strict data type- 4 digit year" or "strict do not allow user to overide validation". Users get an error page upon submitting forms if it is incorrectly filled out. That is, if the fields are empty or don't have valid date entries they get the error page. The problems is that even if the user doesn't finish entering the information to create a new record or simply quits out of their browser, new records with blank fields get created. In the last two days I have had about 20-30 new records created that are entirely blank because eventhough they get an error, records are still being created upon every click of the submit button. Is there any way to prevent the creation of records using field validation as there is within Filemaker?
Unable Posted May 24, 2003 Posted May 24, 2003 First, it sounds from this thread like you are using IWP. Cut that out! Develop your pages in CWP. You will have control, not some WYSIWYG app. The best way to handle "not empty", etc. is with JavaScript. You can't use this wonderful technique very readily with IWP. (If you can figure out how to make JavaScript work in IWP you should post your solution in the Sample Files forum.) You can look now in the Sample Files forum for CWP examples. They are free and can help get you started. Good Luck
Peterh Posted May 24, 2003 Posted May 24, 2003 Stevoreeno1 is not necessarily using IWP. I have the same issue using CWP. Surely Javascript is not the only way around this (learning Javascript is still on my todo list!)? I would have thought that if you get the error form, then a record would not be created. Is this a FileMaker issue, or can the CDML be constructed in such a way as to prevent it? Cheers, Peter.
stevoreeno1 Posted May 24, 2003 Author Posted May 24, 2003 I'm not using IWP. That's is why I posted this in CDML.
stevoreeno1 Posted May 24, 2003 Author Posted May 24, 2003 "Is this a FileMaker issue, or can the CDML be constructed in such a way as to prevent it?" Wha'ts up with that? Get an error message with minimul restrictions- allowing the creation of records. I don't get that.
EddyB Posted May 24, 2003 Posted May 24, 2003 Hi, I do not think this is a FileMaker problem. I have a field on my database that cannot be empty and I am using CWP If users try to submit with that field empty, they receive an error message screen and the record is not added to the database, I suspect the problem is with your CDML. Ed.
Anatoli Posted May 24, 2003 Posted May 24, 2003 The same is here, blank records are not getting created.
Unable Posted May 24, 2003 Posted May 24, 2003 I believe that in FMPro 4.0 the field validation does not work over the web. However in 5+ it does work. There are reasons to use JavaScript for validating required fields. First and foremost it does not put a processing load on the db/website, but is handled on the client's side. Secondly, with JavaScript, a message can inform the client of which field needs attention. Field validation code exists (there are several JavaScript sites), so one does not need to learn JavaScript. One only needs to edit it.
Leb i Sol Posted May 24, 2003 Posted May 24, 2003 if ur on dreamweaver you do not need to "know" java script for this...it-DW- comes with built-in form validation and if that is not enough: http://yaromat.com/dw/?t=All&r=All if u do not have DW post the Form of your html and I will gladly do a 2click opertation for you and post the code good luck
stevoreeno1 Posted May 29, 2003 Author Posted May 29, 2003 What could be the problem in the code? Here is the format <form action="FMPro" method=post > <input type=hidden name="-db" VALUE="request.fp5"> <input type=hidden name="-format" VALUE="reply.html"> <input type=hidden name="-lay" VALUE="web"> <input type=hidden name="-error" VALUE="error1.html"> I also have a couple of hidden fields so that when there is a submit, records will be created in related databases. Here is a sample <input type=hidden name="Request_Relate::ques1" VALUE="agree"> I don't know why new records could be created if the error page comes up. Any help?
EddyB Posted May 29, 2003 Posted May 29, 2003 I'm only guessing but the problem could be to do with your hidden fields creating records in related databases. The error is present on the current database not on the related databases, therefore the records will still be created in the related, for those records to be created a record would first NEED to be inserted in the current database, so inserts a blank record. I think the way for you to go from here is Javascript. This will check the fields before any submission to the database is made. Just before the </head> tag in your page, paste this: <SCRIPT LANGUAGE="JavaScript"> function checkRequiredFields(input) { //set variables for checking fields have all been filled //enter the actual field names under requiredFields //enter a nice user friendly description of these fields under fieldNames var requiredFields = new Array("Field1", "Field2", "Field3", "Field4"); var fieldNames = new Array("Field 1","Field 2","Field 3", "Field 4"); //you should not need to change anything below this point var fieldCheck = true; var fieldsNeeded = "nYou need to enter information in the following field(s):nnt"; for(var fieldNum=0; fieldNum< requiredFields.length; fieldNum++) { if ((input.elements[requiredFields[fieldNum]].value == "") || (input.elements[requiredFields[fieldNum]].value == " ")) { fieldsNeeded += fieldNames[fieldNum] + "nt"; fieldCheck = false; } } // ALL REQUIRED FIELDS HAVE BEEN ENTERED if (fieldCheck == true) // SOME REQUIRED FIELDS ARE MISSING VALUES else { alert(fieldsNeeded); return false; } } </script> Now, in your Form Tag call the function: <FORM ACTION="FMPro" METHOD="post" onsubmit="return checkRequiredFields(this)"> Hope this works! - should do! Ed.
stevoreeno1 Posted May 30, 2003 Author Posted May 30, 2003 Hey, thanks alot. I wil try it although I know nothing about writing Javascripts. Do you know of any good resources where absolute novice can find useful stuff to use with cdml? Thanks again.
stevoreeno1 Posted May 30, 2003 Author Posted May 30, 2003 By the way, do know of way to use javascript so that dates must be entered as 4 digit years? Another problem I have encountered is that when users enter something like "01/01/01" it gets entered into Filemaker as "01/01/1901". No matter what instruction I give the users , somebody always ignores them.
Leb i Sol Posted May 30, 2003 Posted May 30, 2003 Yaromat.com has it......again...if you want post all the form elements I would gladly click few times for you.LAST OFFER here is what the DW generated: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Validate Date</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script language="JavaScript" type="text/JavaScript"> <!-- function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function YY_checkform() { //v4.65 //copyright ©1998,2002 Yaromat.com var args = YY_checkform.arguments; var myDot=true; var myV=''; var myErr='';var addErr=false;var myReq; for (var i=1; i<args.length;i=i+4){ if (args[i+1].charAt(0)=='#'){myReq=true; args[i+1]=args[i+1].substring(1);}else{myReq=false} var myObj = MM_findObj(args[i].replace(/[d+]/ig,"")); myV=myObj.value; if (myObj.type=='text'||myObj.type=='password'||myObj.type=='hidden'){ if (myReq&&myObj.value.length==0){addErr=true} if ((myV.length>0)&&(args[i+2]==1)){ //fromto var myMa=args[i+1].split('_');if(isNaN(parseInt(myV))||myV<myMa[0]/1||myV > myMa[1]/1){addErr=true} } else if ((myV.length>0)&&(args[i+2]==2)){ var rx=new RegExp("^[w.=-]+@[w.-]+.[a-z]{2,4}$");if(!rx.test(myV))addErr=true; } else if ((myV.length>0)&&(args[i+2]==3)){ // date var myMa=args[i+1].split("#"); var myAt=myV.match(myMa[0]); if(myAt){ var myD=(myAt[myMa[1]])?myAt[myMa[1]]:1; var myM=myAt[myMa[2]]-1; var myY=myAt[myMa[3]]; var myDate=new Date(myY,myM,myD); if(myDate.getFullYear()!=myY||myDate.getDate()!=myD||myDate.getMonth()!=myM){addErr=true}; }else{addErr=true} } else if ((myV.length>0)&&(args[i+2]==4)){ // time var myMa=args[i+1].split("#"); var myAt=myV.match(myMa[0]);if(!myAt){addErr=true} } else if (myV.length>0&&args[i+2]==5){ // check this 2 var myObj1 = MM_findObj(args[i+1].replace(/[d+]/ig,"")); if(myObj1.length)myObj1=myObj1[args[i+1].replace(/(.*[)|(].*)/ig,"")]; if(!myObj1.checked){addErr=true} } else if (myV.length>0&&args[i+2]==6){ // the same var myObj1 = MM_findObj(args[i+1]); if(myV!=myObj1.value){addErr=true} } } else if (!myObj.type&&myObj.length>0&&myObj[0].type=='radio'){ var myTest = args[i].match(/(.*)[(d+)].*/i); var myObj1=(myObj.length>1)?myObj[myTest[2]]:myObj; if (args[i+2]==1&&myObj1&&myObj1.checked&&MM_findObj(args[i+1]).value.length/1==0){addErr=true} if (args[i+2]==2){ var myDot=false; for(var j=0;j<myObj.length;j++){myDot=myDot||myObj[j].checked} if(!myDot){myErr+='* ' +args[i+3]+'n'} } } else if (myObj.type=='checkbox'){ if(args[i+2]==1&&myObj.checked==false){addErr=true} if(args[i+2]==2&&myObj.checked&&MM_findObj(args[i+1]).value.length/1==0){addErr=true} } else if (myObj.type=='select-one'||myObj.type=='select-multiple'){ if(args[i+2]==1&&myObj.selectedIndex/1==0){addErr=true} }else if (myObj.type=='textarea'){ if(myV.length<args[i+1]){addErr=true} } if (addErr){myErr+='* '+args[i+3]+'n'; addErr=false} } if (myErr!=''){alert('The required information is incomplete or contains errors:tttttnn'+myErr)} document.MM_returnValue = (myErr==''); } //--> </script> </head> <body> <form action="" method="post" name="form1" onSubmit="YY_checkform('form1','Date','#^([0-9][0-9])/([0-9][0-9])/([0-9]{4})$#2#1#3','3','Please Enter the date in Format: 01/22/2002');return document.MM_returnValue"> <input name="Date" type="text" id="Date"> <input type="submit" name="Submit" value="Submit"> <input type="reset" name="Submit2" value="Reset"> </form> </body> </html> good luck!
clevow Posted June 5, 2003 Posted June 5, 2003 this doesn't seem to work when there are multiple forms on a page. any ideas? i've got a form that gets generated on a per record basis (that is, the form tags are inside the [fmp-record][/fmp-record] tags. I have another javascript i've used with FMP in the past and it won't work on this page either.
Leb i Sol Posted June 5, 2003 Posted June 5, 2003 hi clevow! Do u mean to say that you can have an X number of forms? is there are true need for this? you could use <form> [FMP_Record] [/FMP-Record] </form> but I don't know if the form tags are there for a purpose or just a design overlooked. What is the purpose of the forms?(update,delate, pass token??)...perhaps u could use just one?! the script should work for multiple forms..dropping a >name="form1"< could help. Also, please note that this JS is mega JS that can validate a whole lot more than just a date...
clevow Posted June 5, 2003 Posted June 5, 2003 I was actually referring to the script posted by Eddy. The page this is being used on is a catalog of things that can be ordered. Every item has a submit button next to it that creates a new record (-new). The whole thing is kind of a shopping cart scenario. I just need to make sure that when someone "Adds to Cart" they have chosen a color, size, and quantity of said item. Thanks for the help, Carrie
Leb i Sol Posted June 5, 2003 Posted June 5, 2003 oh OK.... here is a link that might be of use...perhaps not http://javascript.internet.com/forms/validate-date.html and of course:http://javascript.internet.com/forms/
Garry Claridge Posted June 5, 2003 Posted June 5, 2003 You will need to uniquely identify each Form to the Script. All the best. Garry
Recommended Posts
This topic is 7911 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now