Page 1 of 1

Hide Fields and set fields required conditionally

Posted: 02 Jun 2014
by Vinay Muppidi
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

Re: Hide Fields and set fields required conditionally

Posted: 03 Jun 2014
by Dmitry Kozlov
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;
});

Re: Hide Fields and set fields required conditionally

Posted: 03 Jun 2014
by Vinay Muppidi
Thanks Dmitry..It worked..these forms are looking very promising especially for SharePoint foundation users..