Copy link to clipboard
Copied
I have a cfform with regular expression validation. I was wondering if there is any way to not have the form submit when enter is hit. Currently it validates if you hit enter to go to the next form field.
Any ideas?
Copy link to clipboard
Copied
To control whether or not to submit the form, use actionscript as the value of cfform's onSubmit attribute. If the last line of the script is return false, the form wont submit. An example follows
<cfif isDefined('form.test')>
<cfdump var="#form#">
</cfif>
<cfform method="post" format="flash" onsubmit="return submit_it()">
<cfformitem type="script">
function submit_it(){
// to test, toggle between true and false
return true;
}
</cfformitem>
<cfinput type="submit" name="sbmt" value="Test it!">
<cfinput type="text" name="test">
</cfform>
Copy link to clipboard
Copied
THANK YOU. I'm trying to figure this out for last 3 hour, onSubmit and Actionscript.
But ow can i check it against regular expression?
Please help me correct the following code:
var y = "[A-Z]{1,3}"
var x = check1.text
if(!(x.match(y))){
return false;}
else
{ return true;}
Copy link to clipboard
Copied
sunny_2010 wrote:
THANK YOU. I'm trying to figure this out for last 3 hour, onSubmit and Actionscript.
But ow can i check it against regular expression?
Please help me correct the following code:
var y = "[A-Z]{1,3}"
var x = check1.textif(!(x.match(y))){
return false;}
else
{ return true;}
This is Actionscrionscript, but is unrelated. You should have started your own thread.
In any case, you could easily look up the usage of match() on the web. You will find that
1) it takes a RegExp pattern as parameter;
2) it returns an array, not a boolean
Your if-statement could therefore test for array length instead. The same link gives you documentation on the search() method. It returns an integer, and so is simpler to use in testing a match.