Skip Navigation

[Resolved] Javascript not making some fields required

This support ticket is created 7 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 -
- 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 7 replies, has 2 voices.

Last updated by Noman 7 years, 3 months ago.

Assisted by: Noman.

Author
Posts
#562250

The solution given in this reply no longer seems to be working and I can't understand why.

I am trying to make the availability and Your CV fields required in the form hidden link

I am using this script

jQuery( document ).ready(function() {
jQuery("input[name='wpcf-availability']").prop('required',true);
jQuery("input[name='wpcf-text-cv']").prop('required',true);
console.log('ready');
});

and the form is


[creduserform class='cred-user-form cred-keep-original']

	[cred_field field='form_messages' value='']
<label class="cred-label">
  Role applied for
</label>
[cred_field field='role-applied-for' post='user' value='[getrole]' urlparam='']

	
<div class="cred-field cred-field-user_login">
		<label class="cred-label">
Username (one you can remember...this is for access to our Intranet, RV:INSIDE)
</label>
		[cred_field field='user_login' post='user' value='' urlparam='']
	</div>

	<div class="cred-field cred-field-user_email">
		<label class="cred-label">
Email
</label>
		[cred_field field='user_email' post='user' value='' urlparam='']
	</div>

	<div class="cred-field cred-field-first_name">
		<label class="cred-label">
First Name
</label>
		[cred_field field='first_name' post='user' value='' urlparam='']
	</div>

	<div class="cred-field cred-field-last_name">
		<label class="cred-label">
Last Name
</label>
		[cred_field field='last_name' post='user' value='' urlparam='']
	</div>

	<div class="cred-field cred-field-addr1">
		<label class="cred-label">
Address Line 1
</label>
		[cred_field field='addr1' post='user' value='' urlparam='']
	</div>

	<div class="cred-field cred-field-addr2">
		<label class="cred-label">
Address Line 2
</label>
		[cred_field field='addr2' post='user' value='' urlparam='']
	</div>

	<div class="cred-field cred-field-city_town">
		<label class="cred-label">
City/Town
</label>
		[cred_field field='city_town' post='user' value='' urlparam='']
	</div>

	<div class="cred-field cred-field-post_code">
		<label class="cred-label">
Postcode
</label>
		[cred_field field='post_code' post='user' value='' urlparam='']
	</div>

	<div class="cred-field cred-field-main_phone">
		<label class="cred-label">
Main Phone
</label>
		[cred_field field='main_phone' post='user' value='' urlparam='']
	</div>

	<div class="cred-field cred-field-alternative_phone">
		<label class="cred-label">
Alternative Phone
</label>
		[cred_field field='alternative_phone' post='user' value='' urlparam='']
	</div>

<div class="cred-field cred-field-date-of-birth">
		<label class="cred-label">
Date of Birth
</label>
		[cred_field field='date-of-birth' post='user' value='' urlparam='' required='true']
	</div>

<div class="cred-field cred-field-previous-experience">
	<label class="cred-label">
Previous Experience
</label>
		[cred_field field='previous-experience' post='user' value='' urlparam='']
	</div>

<div class="cred-field cred-field-text-cv">
	<label class="cred-label">
Your CV
</label>
		[cred_field field='text-cv' post='user' value='' urlparam='' class='form-control' output='bootstrap' required='true']
	</div>
<div class="cred-field cred-field-availability">
<label class="cred-label">
Your availability (please say when you are generally available - you can pick multiple times)
</label>

[cred_field field='availability' post='user' value='' urlparam='']
</div>

[cred_generic_field field='Confirm' type='checkbox' class='' urlparam='']
{
"required":1,
"validate_format":0,
"checked":0,
"default":"1",
"label":""
}[/cred_generic_field] I confirm I have read and understand the <a href="<em><u>hidden link</u></em>" target="_blank">volunteer handbook</a>, <a href="<em><u>hidden link</u></em>" target="_blank">safeguarding policy</a>, and <a href="<em><u>hidden link</u></em>" target="_blank">issue resolution process</a>

[cred_show_group if="($(Confirm) eq  '1' )"  mode='fade-slide']
Date
[cred_field field='volunteer-compliance-confirmed' post='user' value='[wpv-post-today]' urlparam='' readonly='false']
	[cred_field field='form_submit' value='Submit' urlparam='']

[/cred_show_group]

[/creduserform]

#562318

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Nick,

Thank you for contacting Toolset support. From the debug info I can see that you are using older version of CRED, so please make sure to use latest version of Toolset plugins, CRED 1.9.2 is released with the fixes:
https://toolset.com/download/toolset-cred/

If issue still exists, please provide temporary website WP-admin and FTP info for your site to debug further and to help in resolving this. Your next answer will be private which means only you and I have access to it.

=== Please backup your database and website ===

✙ I would additionally need your permission to de-activate and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important.

✙ Please add the Links to the [Form] Edit Screen.

Thanks

#562526

Looks like my last reply was NOT private?

#562527

I have reset the passwords; when you confirm you have set private reply I will back up again and share new access details

#562539

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Sorry something went wrong. I have removed last public message and re-enabled the private fields now, so you can share the login details.

Thanks

#563169

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thanks for waiting on this. I have updated jQuery code in CRED Form >> JS editor as below:

jQuery( document ).ready(function() {
	jQuery("input[name='wpcf-availability[]']").prop('required',true);
	jQuery("textarea[name='wpcf-text-cv']").prop('required',true);
	console.log('ready');
});

And now its working good only in this CRED form frontend:
hidden link

I hope this resolves the issue. Thank you

#563312

Thanks. So I don't bother you next time, can you tell me what the issue was please?

Nick.

#563325

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Yes sure, here is the reason:

jQuery("input[name='wpcf-availability']").prop('required',true);

-- In above line of code, you were targeting checkbox field slight incorrect.
You were using wpcf-availability instead of wpcf- availability[]

jQuery("input[name='wpcf-text-cv']").prop('required',true);

-- In above line of code, CV field was not an input field, it was textarea field.
You were using input instead of textarea.

Have a great day, Thank you