Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
bifnaked99 #1
Dynamic Validation of Required Fields
I am currently using a standard HTML form in which a user must enter certain
data (required). The form has 2 submit buttons, 1 of which changes the default
form action to go to a different page. This second submit button does not
require the same information to be passed as the standard form. I am trying to
move to using cfforms for better data validation, but I am having difficulty
turning off the unnecessary required fields for the second submit button.
Any ideas?
bifnaked99 Guest
-
Make DateField required with validation
I need a DateField to be required so it shows an error if it gains focus and then loses focus without being set. I have seen some examples, but they... -
CFINPUT validation & required being bypassed
Hi all, Ok this one i've never seen before. I've used these tags for years.. So i've setup a simple CFINPUT tag to collect a phone number that is a... -
conditional required cfform field + customjavascript validation
Thanks for responding. Here's the code I'm using to do this. Perhaps it will allow a better understanding of what I'm trying to accomplish. I'm... -
email validation without being required
Here's a more robust regular expression that works with required='no' in Cold Fusion 5. It is adapted from the article:... -
Netscape required field validation problems
I have an interesting problem when I run the following code in Netscape (7.02) vs. IE. This page works great in IE and all my controls bring up the... -
bigdawg_ruff #2
Re: Dynamic Validation of Required Fields
Bif, you will have to create separate functions for each submit button, then
pass variables created from those functions to a third (Submit) function:
<input type="Submit" name="subform" value="Save" onclick="maketrue();" >
<input type="Submit" name="subform1" value="Publish" onclick="checklesson();">
clicking on either one of these buttons will cause the onclick function and
the submit function to execute
Create the functions
<script language="VBScript">
lesson=True \\SETS THE PARAMETERS EQUAL TO TRUE, THESE WILL BE USED TO SUBMIT
THE FORM
titlecheck=True
Function checklesson()
If frmlesson.txttitle.value="" Then \\IF A FORM FIELD IS LEFT NULL
msgbox "Required Field: Lesson Title",48,"Lessons Learned
Tool"
frmlesson.txttitle.focus()
lesson=False
titlecheck=False
Exit Function
Else
titlecheck=True
lesson=True
End If
End Function
\\NOTICE THIS FUNCTION DOES NOT STOP FORM SUBMISSION
Function maketrue()
lesson=True
titlecheck=True
End Function
Function frmlesson_onsubmit()
If frmlesson.txttitle.value="" AND titlecheck=True Then
msgbox "Required Field: Lesson Title",48,"Lessons Learned Tool"
frmlesson.txttitle.focus()
frmlesson_onsubmit=False
Exit Function
End If
If lesson=False Then
frmlesson_onsubmit=False
Exit Function
End If
End Function
</script>
EACH FUNCTION WILL SET THE "titlecheck" OR "lesson" VARIABLE EQUAL TO
TRUE/FALSE IF NECESSARY, THEN THE FINAL FUNCTION IS USED WHEN THE FORM IS
SUBMITTED. YOU MUST PLACE THE TRUE/FALSE VARIABLES AND FUNCTIONS CAREFULLY
BASED UPON HOW THE USER WILL USE THE PAGE. USER COULD CLICK THE SECOND BUTTON,
THEN CLICK THE FIRST ONE AND BASED UPON THE PLACEMENT IN THE VB SCRIPT, IT
COULD CAUSE THE FORM TO SUBMIT WHEN IT SHOULD NOT
bigdawg_ruff Guest



Reply With Quote

