Hide Fields and set fields required conditionally

rss

Posted by Vinay Muppidi - Jun 2 ’14 at 03:08

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

 

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 8 years 8 months
    #1 by Dmitry Kozlov Jun 3 ’14 at 07:11

    Hello,

    1

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

    $('.your-class-name').hide().
    

    You can also get the specific field by its internal name and hide it in a similar manner:

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

    2

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

    fd.onsubmit(function() {
    	if (!fd.field('Title').value()) {
    		alert('Please, fill in the Title field.');
    		return false;
    	}
    	return true;
    });
    
  • Vinay Muppidi
    Vinay Muppidi
    Member
    Member for: 7 years 11 months 19 days
    #2 by Vinay Muppidi Jun 3 ’14 at 07:49

    [#1]: Thanks Dmitry..It worked..these forms are looking very promising especially for SharePoint foundation users..

Displaying 1 to 2 of 2 messages