1

I have a recaptcha widget in my form and i want it to be made mandatory. since i dont have any direct control over the widget in my html, i was wondering if i can add the required attribute to it after it has been rendered.

ie. if i add the folloing css

#recaptcha_response_field{background-color:#000000;}

it does color up the recaptcha widget text field. in the same vein, if there was some way of setting the required="required" attribute for input fields via css, i'd be able to make it mandatory.

Rishav Sharan
  • 2,763
  • 8
  • 39
  • 55

2 Answers2

3

Does the following work for you:

$(function() {
    $("#recaptcha_response_field").attr('required','required');
});
mreyeros
  • 4,359
  • 20
  • 24
1

If I understand you correctly, this should do the trick:

$(function() {
    $("#recaptcha_response_field").css({background-color:#000000;});
});

Without jQuery:

document.onload = function() {
    document.getElementById("recaptcha_response_field").style['background-color'] = '#000000';
};

I'm not 100% sure on the second one, but I can't test it right now.

Elliot Bonneville
  • 51,872
  • 23
  • 96
  • 123
  • i think you misunderstood me. i wanted to put the attribute "required" on the field. I gave an example where i can put in the style on the field. I just wanted to know if it was possible to put in the required attribute in a similar way. – Rishav Sharan Apr 05 '12 at 19:50