Title: Message

Use the submit button – have your validation script return true or false for passed and failed respectively which it looks like you’ve got already, then have something like this…

 

<input type=”submit” value=”Submit” >return chkRevision();”>

 

If validation fails, the button never triggers, if it passes, it triggers and invokes the form’s onSubmit handler .

 


From: Rich Wild [mailto:[EMAIL PROTECTED]
Sent: 29 June 2004 15:14
To: [EMAIL PROTECTED]
Subject: RE: [ cf-dev ] cfform[Scanned]

 

Thanks Mark, I agree – but how can I stop this happening and actually get cfform to kick off an extra custom validation (ie mine) after *its* finished?

 


From: Mark Smyth [mailto:[EMAIL PROTECTED]
Sent: 29 June 2004 15:10
To: [EMAIL PROTECTED]
Subject: RE: [ cf-dev ] cfform[Scanned]

 

I think its the onsubmit Rich

 

When cfform creates the _javascript_ is initiates the validation by dynamically adding an onsubmit

 

so what you'd end up with in the browser is something like

 

<FORM NAME="itemFrm" ACTION="" METHOD="POST" _CF_checkitemFrm(this)" ENCTYPE="multipart/form-data">

 

its basically overwritting your onsubmit, or it sounds like they might even be conflicting

hth

mark

-----Original Message-----
From: Rich Wild [mailto:[EMAIL PROTECTED]
Sent: 29 June 2004 14:48
To: [EMAIL PROTECTED]
Subject: [ cf-dev ] cfform

Yuck. I've inherited code which I'm debugging and it all uses cfform, a personal peeve of mine.

 

Now, perhaps its because I came back from Glastonbury yesterday and so am a little bit mental, but I'm trying to get this cfform to fire off a validation script on submit.

 

So I've added the onsubmit parameter to the cfform call like thus:

 

<cfform action="" method="POST" name="itemFrm" enctype="multipart/form-data" chkRevision();">

 

And I have the following function declared just above it like thus:

 

<script>

function chkRevision() {

                        if (document.itemFrm.revision.value && !document.itemFrm.EditComments.value.length) {

                                    alert('Warning!\n\nPlease ensure that you have completed the \'Edit Comments\' field.');

                                    return false

                        } else {

                                    return true

                        }

            }

</script>

 

That should work yea? So why does the JS give me a Object Not Found error when run at the browser on this line (which is obviously created by cfform)

 

function  _CF_checkitemFrm(_CF_this)

{

            if  (!_CF_hasValue(_CF_this.title, "TEXT" ))

            {

                        if  (!_CF_onError(_CF_this, _CF_this.title, _CF_this.title.value, "Please enter Title"))

                        {

                                    return false;

                        }

            }

return chkRevision();

 

            return true;

}

 

p.s. I *would* dearly love to turn the whole form into a normal form, but there's a lot of work required (large form) to do that and this is a quick fix, very unfortunately.

 

I think I've left my mind in a field.

 

Ta everyone.

 

Rich

Reply via email to