Hide Fields and set fields required conditionally

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
Vinay Muppidi
Posts: 9
Joined: Mon Jun 02, 2014
Contact:

02 Jun 2014

Hello,

I have a couple of questions:

1. How to we HIDE fields dynamically, I was able to set Read Only but not hide.

2. titleRequired(value) only puts an asterisk but does not really validate on submit. How do we make controls required and validate them dynamically.

Apart from the javascript methods explained here 'http://spform.com/documentation/js/field' can we use other methods? If so can you please provide a sample.


Thanks

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

03 Jun 2014

Hello,

1

You may assign a CSS-class to a field and use this class in JavaScript to hide the field:

Code: Select all

$('.your-class-name').hide().
You can also get the specific field by its internal name and hide it in a similar manner:

Code: Select all

$('.fd_field[fd_name="InternalName"]').hide();
2

Please, add your custom validation code into onsubmit handler. Example:

Code: Select all

fd.onsubmit(function() {
	if (!fd.field('Title').value()) {
		alert('Please, fill in the Title field.');
		return false;
	}
	return true;
});

Vinay Muppidi
Posts: 9
Joined: Mon Jun 02, 2014
Contact:

03 Jun 2014

Thanks Dmitry..It worked..these forms are looking very promising especially for SharePoint foundation users..

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 8 guests