I have a long formular to let users sign up to a conference.
There are some radiobuttons and I want them to use as required fields.
How can I do this?
Radiobutton as required field
(4 posts)
(2 voices)
-
Posted 1 year ago #
-
Hello juwe,
Just to make sure I understand correctly. You added some radio buttons to the contact form and you want to make them required fields?
Posted 1 year ago # -
Hi Elliott,
that's exactly what I want.
Posted 1 year ago # -
This is a little complex juwe. You will want to add the class "requiredField" to your radio button elements and then open up
js/custom.jsand on lines 261 - 276 you can find the validation code,jQuery('.requiredField').each(function() { if(jQuery.trim(jQuery(this).val()) == '') { var labelText = jQuery(this).prev('label').text(); //jQuery(this).parent().append('<span class="error">You forgot to enter your '+labelText+'.</span>'); jQuery(this).addClass('inputError'); hasError = true; } else if(jQuery(this).hasClass('email')) { var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/; if(!emailReg.test(jQuery.trim(jQuery(this).val()))) { var labelText = jQuery(this).prev('label').text(); //jQuery(this).parent().append('<span class="error">You entered an invalid '+labelText+'.</span>'); jQuery(this).addClass('inputError'); hasError = true; } } });You can try it by itself but you might have to add a section for your radio buttons.
Posted 1 year ago #
Reply
You must log in to post.













