Coldfusion Cfform bug/error: “_b is undefined”

While coding a HTML form using Coldfusion’s CFForm, I encountered a bug that threw a javascript error while submitting it.

"_b is undefined" from cfform.js

around line 3:

_CF_hasValue=function(_b,_c,_d){
if(_c=="TEXT"||_c=="FILE"||_c=="PASSWORD"||_c=="CFTEXTAREA"||_c=="TEXTAREA"||_c=="CFTEXTINPUT"||_c=="DATEFIELD"){
if(_b.value.length==0){
return false; 
}else{
if(_d){
str=_b.value.replace(/^\s+/,"").replace(/\s+$/,"");
if(str.length==0){
return false;
}
} 

One of the problems with errors while submission is that it happens very quickly and the browser redirects. So the user doesn’t see the javascript error. It also breaks execution of any (onsubmit/event) javascript code.

I went through my cfform to find any problems code. However at the end, I noticed that the cfform tag was missing the “name” attribute, and by simply adding the “name” attribute I was able to avoid the error.

This is one of the reasons I do not like ColdFusion’s helpers, because the errors that they sometimes generate are very misleading and not documented.

4 thoughts on “Coldfusion Cfform bug/error: “_b is undefined””

  1. When we use third party javascript within form validation, we are shown the same error message you defined. We named our form as shown here:

    form fields….

    but we are still experiencing the same “_b is undefined” error.

    Any ideas?

Leave a Comment