TimeOnly field on form locked but not disabled - javascript

I've added a DateTime field and made it show only time without date on my main form. The mian form has other fields as well like lookup, text fields and default DateTime fields. I'm trying to disable all the fields on form load event using this code:
Xrm.Page.ui.controls.forEach(function (control, i) {
if (control && control.getDisabled && !control.getDisabled()) {
control.setDisabled(true);
}
});
The problem that I'm facing is that all the fields are disabling except the time only field on the form. Although the field show the lock icon but I can still change the time in the field and only after pressing ctrl+f5 on my browser the timeonly fields gets properly disabled.
This is how I've set time only property to a DateTime field on my form:

Related

How to Validate Form fields one by one with Parsley Js

I am trying to Validate a Form with Parsley JS But when I hit submit it's adding error class in all fields but I want that it should validate fields one by one.
So if the 5 inputs are required and I it submits without filling any of them so want to show error in the 1st input only. after that if i fill 1st input and left the other 4 then it should show error in the second input only. I am just using this code for my form now.
$('#formid').parsley( //nothing here for now );
Set a specific priority to each input in the order you want them validated. Parsley will stop validation as soon as an error is detected at a given priority level.

How to make an option set field read-only on Save in MS Dynamics CRM 2011, so that for the next time it will be a read-only field

I am using below script to make my field read-only on CRM form while saving it. My requirement is for the first time it should be editable for user and once user select value and save the form its should be read-only for the next time. but with below script whenever I am refreshing the form field will become editable again.
function Test() {
debugger;
Xrm.Page.ui.controls.get("new_test").setDisabled(true);
Xrm.Page.data.entity.attributes.get("new_test").setSubmitMode("always");
//Xrm.Page.getAttribute("new_test").setSubmitMode("always");
Xrm.Page.data.entity.save();
}
You have to do it in form onLoad not onSave. If the picklist already have value selected, then disable it.
Call this formOnLoad() method in form onLoad event.
function formOnLoad() {
debugger;
if(Xrm.Page.getAttribute("new_test").getValue() != null){
Xrm.Page.ui.controls.get("new_test").setDisabled(true);
}
}

What changes to DOM are made when MVC Validation triggers?

I have a form in a modal window that is currently performing some validation.
(I am using ASP.NET MVC, JQuery UI, ajax forms, data annotations and unobtrusive is active)
When this validation triggers I have noticed so far that it does a few things:
1: my validation summary gets it's class changed from .validation-summary-valid to .validation-summary-errors
2: my invalid inputs have a class added to then called .input-validation-error
3: my validation messages get their class changed from .field-validation-valid to .field-validation-error
But there is something else that it is doing and I cant work out how it is tracking this.
I have a textbox that is required, before triggering the validation i can select inside this box, then select another box and the validation will be silent.
But as soon as i trigger the validation by clicking submit with an empty textbox, i can select the textbox and type something to remove the validation instantly, but if i then null it and select a different box this error is re-applied without re-submitting.
So my question is: what has changed, how does it know that I have attempted to submit already?
When validate is called, it adds a class to each input/select that is supposed to be validated. When the input/select is not valid it adds a class to the input/select:
class="input-validation-error"
When it is valid, it adds:
class="valid"
Validation only fires on the control when you change the value, not when it loses focus.
Validation fires on change, even before you submit the form. Take a required textbox, add a value to it, and tab off ... then go back and remove that value, and you should see the textbox highlighted red.

javascript and dynamic data

I'm using Dynamic Data 4 on my project.
In a template field there's a button that modify (via javascript) the value of the databound input field.
The button modify the input box value correctly but when the input field get the focus his value it's resetted to the previous value. The same happens when saving the form. If the input box previously received input from the keyboard the value it's correctly stored.
Is that behaviour to be considered normal with those premises? There's a way to avoid it?
Thank you very much.
The problem was caused by the presence of an associated asp:TextBoxWatermarkExtender who resetted the value when the (originally null) textbox got the focus.

Clientside validation of a textbox

I have an asp.net control textbox, clicking on which a jquery timepicker appears and user can select any time.But I want to validate the selected time so that it is one hour greater than the current time in the client side. I mean when textbox value will be changed it should be validated. Can anyone help me how to do this?
The input that the client's selection goes into will have an id. Do
$('#that_id').change(function() {
Validation Code/////
})

Categories