Does anyone have a sample validation applet they could share? I am using cfgrid (non-flash) and need to validate a date field and a float field. I can't find any non-flash examples and I need to get this working ASAP. Thanks in advance.
CFGrid OnValidate Validation Applet Example
Collapse
X
-
-
I'm using a very simple validation just to make sure I'm doing it correctly. When I display the value object in the js module, I get a complex value. Do I need to somehow parse that value in order to determine the row data? Also, when I display the field object, I only get [object]. Any lead you can give me will be greatly appreciated.Originally posted by acoderSee this link from the docs. If you get stuck, post your code.
Coldfusion
Javascript:Code:<cfgrid name="TRGrid" query="grid" width="725" height="300" onchange="showSave();" onvalidate="validateFields" rowheaders="yes" colheaders="yes" colheaderalign="center" colheaderbold="yes" selectmode="edit" insert="yes" delete="yes" insertbutton="Add New Task" deletebutton="Delete Selected Task" > <cfgridcolumn name="CatDesc" header="Category" width="125" select="no"> <cfgridcolumn name="TaskID" header="Task" width="250" values="#TaskIDList#" valuesdisplay="#TaskDescList#"> <cfgridcolumn name="ActivityID" header="Activity" width="165" values="#ActIDList#" valuesdisplay="#ActDescList#"> <cfgridcolumn name="ActivityDate" header="Date" width="75" dataalign="right" mask="mm/dd/yy" type="string_nocase"> <cfgridcolumn name="Hours" header="Hours" width="65" dataalign="right" numberformat="00.00" type="numeric"> <cfgridcolumn name="ID" display="no" width="100"> <cfgridcolumn name="EmpID" display="no" header="Employee" width="100"> <cfgridcolumn name="CategoryID" display="no" header="Category" width="100"> </cfgrid>
Code:function validateFields(form, field, value) { //Check for date field if (field == "ActivityDate") { if(value.length < 8) { alert("A date value is incorrect. Please enter the date as mm/dd/yy."); return false; } else { return true; } } //check for other fields here. else { return true; } }Comment
-
Yes. The cfform contains a 2-column table: left side has some filtering links, right column displays the grid. I use a stored procedure to fill the grid and custom queries code to insert/delete/update the rows. Everything works great. Now I'm just trying to validate the date and hours columns.Originally posted by acoderJust to confirm, this cfgrid is within a cfform?Comment
-
Do you mean an alert here? You could try checking the HTML/JavaScript source to see what's passed through.Originally posted by prosetxWhen I display the value object in the js module, I get a complex value. Do I need to somehow parse that value in order to determine the row data? Also, when I display the field object, I only get [object].
PS. I don't program with onValidate much.Comment
-
I just put an alert there for testing only. I did check the values being passed and the string is some type of concatenated list. I don't know if I'm suppose to parse it or use some special technique to determine the grid column and grid value being checked.Originally posted by acoderDo you mean an alert here? You could try checking the HTML/JavaScript source to see what's passed through.
PS. I don't program with onValidate much.Comment
Comment