Question

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.

Was it helpful?

Solution

Does the following work for you:

$(function() {
    $("#recaptcha_response_field").attr('required','required');
});

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top