INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

invalid form control with name='' is not focusable

invalid form control with name='' is not focusable

(OP)
Hi,

This is doing my head in.

Yes, I've researched and all the threads I can find waffle on about a hidden form field causing the problem.

But I don't have one?

I've done a console.log($(':hidden')) and none of the elements are part of the form and definitely none matching $('[required]')

It's not happening when I run my validation ..

CODE

function checkValid(ele)
{

  try
  {
    if($(ele).prop('tagName') == 'TEXTAREA')
    {
      validateTextarea.call(ele);
    }    
    
    if($(ele).prop('validity').valid)
    {
      var remove = 'invalid';
      var add = 'valid';
      
      if($(ele).attr('minlength') && $(ele).attr('minlength') > $(ele).val().length)
      {                   
        var remove = 'valid';
        var add = 'invalid';
      }
      else if ($(ele).attr('maxlength') && $(ele).attr('maxlength') < $(ele).val().length)
      {                     
        var remove = 'valid';
        var add = 'invalid';
      }
        
      $(ele).removeClass(remove);
      $(ele).addClass(add);
    }
    else
    {               
      $(ele).removeClass('valid');
      $(ele).addClass('invalid');
    }
  }
  catch(e){};

  if(!$(ele).prop('required') && $(ele).val() == '')
  {
    $(ele).removeClass('valid');
  }

  // trigger validate event
  $( document ).trigger('validated');          
}


function validateTextarea()
{         
  var errorMsg = "Please match the format requested.";
  var textarea = this;
  var pattern = new RegExp('^' + $(textarea).attr('pattern') + '$');
  var rev_pattern =  new RegExp($(textarea).attr('pattern').replace(/^\[/,'[^'));
  $(textarea).val($(textarea).val().replace(rev_pattern, ''));
  
  // check each line of text
  $.each($(textarea).val().split("\n"), function () {
    // check if the line matches the pattern
    var hasError = !this.match(pattern);
    if (typeof textarea.setCustomValidity === 'function')
    {
      textarea.setCustomValidity(hasError ? errorMsg : '');
    }
    else
    {
      // Not supported by the browser, fallback to manual error display...
      $(textarea).toggleClass('invalid', !!hasError);
      $(textarea).toggleClass('valid', !hasError);
      if (hasError)
      {
        $(textarea).attr('title', errorMsg);
      }
      else
      {
        $(textarea).removeAttr('title');
      }
    }
   return !hasError;
  });
} 

My validation icons all work fine, but when the form is submitted, if there is a visible, but not valid element, that error occurs in the console. but the in-built browser validation message still appears 'Please fill in this field'.. blah blah ..

What is causing this error? Is it a bug in Chrome on Linux or am I going blind?

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music

RE: invalid form control with name='' is not focusable

(OP)
I found the answer....

Quote:



It is a bug in Chrome related to the first <fieldset>. If you remove it then the error doesn't appear. Even if you give the fieldset a name Chrome will still give the error.

https://code.google.com/p/chromium/issues/detail?i...

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close