Change color of fields. Select all fields of a class
Hi There
I have 2 questions:
I'm trying to add a CSS class to multiline plain textareas when another field changes. I tried all the following CSS selector, but it won't change:
.required textarea {
border: 2px solid #AA88FF;
background-color: #FFEEAA; }
.required input[type='text'] {
....
}
.required input {
.....
}
.required .ms-rtefield {
...
}
Code handling:
fd.field('Scope').change(function(){
if (val != 1) {
fd.field('Scope_x0020_Txt').titleRequired(true);
fd.field('Scope_x0020_Txt').addClass('required');
} });
2. My second question: Is it possible to lets say handle all the fields with a certian class? I was thinking of
$('#required').each(function () {
If field('xyz').value() == '';
}
is it possible?
Thanks a lot for the reply.,.
I have 2 questions:
I'm trying to add a CSS class to multiline plain textareas when another field changes. I tried all the following CSS selector, but it won't change:
.required textarea {
border: 2px solid #AA88FF;
background-color: #FFEEAA; }
.required input[type='text'] {
....
}
.required input {
.....
}
.required .ms-rtefield {
...
}
Code handling:
fd.field('Scope').change(function(){
if (val != 1) {
fd.field('Scope_x0020_Txt').titleRequired(true);
fd.field('Scope_x0020_Txt').addClass('required');
} });
2. My second question: Is it possible to lets say handle all the fields with a certian class? I was thinking of
$('#required').each(function () {
If field('xyz').value() == '';
}
is it possible?
Thanks a lot for the reply.,.
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
Hi,
1. What type of multiline text field do you use: Plain text, Rich text, or Enhanced rich text?
2. Please, use the code below:
1. What type of multiline text field do you use: Plain text, Rich text, or Enhanced rich text?
2. Please, use the code below:
Code: Select all
$.each($('[fd_name]'), function() {
if (fd.field($(this).attr('fd_name')).value() == '') {
...
}
})
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
Please, use the following code to assign an additional CSS class to the field's control:
Regarding the loop through the fields, do you need to loop through a particular type of fields? If so, what type?
Code: Select all
fd.field('Scope_x0020_Txt').control()._el().addClass('required');
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
Please use the following code:
If you need to check if your required fields are empty, you'll need to insert respective checks in place where my comment is. Please note, that different field types' values are retrieved differently.
Code: Select all
var alertMessage;
$.each($('[fd_name]'), function() {
if ($(this).find('.required').length > 0 /**if needed add here a check for emptiness of your fields, field names are retrieved by $(this).attr('fd_name')**/) {
if (alertMessage == undefined) {
alertMessage = "Please fill in the following fields: \n";
}
alertMessage += fd.field($(this).attr('fd_name')).titleText() + "\n";
}
})
if (alertMessage != undefined) {
alert(alertMessage);
}
Thanks, I'm sorry I get i know.
Your code works fine thank you. Though I have another question related to your code:
alertMessage += fd.field($(this).attr('fd_name')).titleText() + "\n";
I always get blanc, although I have set a Title value in the form editor, do I have to add a title in code as well?
The css is working fine for the plain textarea, I tried to apply it to a choice field (dropdownbox) with
.required select
Is this wrong?
Your code works fine thank you. Though I have another question related to your code:
alertMessage += fd.field($(this).attr('fd_name')).titleText() + "\n";
I always get blanc, although I have set a Title value in the form editor, do I have to add a title in code as well?
The css is working fine for the plain textarea, I tried to apply it to a choice field (dropdownbox) with
.required select
Is this wrong?
No you don't have to change title using code. Are you using exactly the code we provided or have you maybe added your own stuff, e.g. conditional statements?
The css selector for a dropdown is exactly what you thought it was. E.g.
.required select {
background-color: #FFEEAA;
}
would do the trick.
If you're using the code we sent you and it doesn't work, please send us the source code of your page (e.g. in Chrome right click -> View page source) to support@spform.com and we'll try to replicate your issue.
The css selector for a dropdown is exactly what you thought it was. E.g.
.required select {
background-color: #FFEEAA;
}
would do the trick.
If you're using the code we sent you and it doesn't work, please send us the source code of your page (e.g. in Chrome right click -> View page source) to support@spform.com and we'll try to replicate your issue.
-
- Information
-
Who is online
Users browsing this forum: No registered users and 20 guests