am using Kendo Ui for our MVC project and being very much new to kendoUI stuck with a problem where i need to disable/enable data-validate rule on one of my testbox on the basis of some business rules.
below is the HTML for control :
<pre><input id="txtLastName" type="text" data-tooltip="external" data-tooltip-text="tooltipdemotext" class="form-control k-textbox" data-validate="true" data-rule-message="Last Name cannot be blank" data-rule-name="required" placeholder="Enter Last Name" /></pre>
Could someone please help me in this.
And the answer was a single line statement of Jquery and nothing to do with Kendo
$('#txtLastName').removeAttr('data-validate');
Thanks
Related
I have created a slickGrid APP and want to have placeholders in the search box. I can see an example in the Angular version of the slickgrid, yet couldnt see its code. I am however using the Javascript version.
Can someone help?
Thank you,
B
Check out http://6pac.github.io/SlickGrid/examples/example-header-row.html as an example.
The filter boxes are created using:
grid.onHeaderRowCellRendered.subscribe(function(e, args) {
$(args.node).empty();
$("<input type='text'>")
.data("columnId", args.column.id)
.val(columnFilters[args.column.id])
.appendTo(args.node);
});
So just add the 'placeholder' attribute to the box, eg:
<input type="text" name="fname" placeholder="First name">
I am trying to use a kendo numeric text box with angular validation (ng-required) however I'm not able to get it working. The ng-required attribute on this element has no effect on the form validation status.
From my understanding, the reason why this doesn't work is because kendo numeric text box uses k-ng-model to store it's value, whereas the angular validation works only with ng-model.
Has anyone else seen this issue, are there any workarounds?
I have found a workaround that involves using the kendo-numeric-text-box along with a hidden input field which makes use of ng-model.
<input data-kendo-numeric-text-box data-k-ng-model="numValue"/>
<input type="hidden" data-ng-model="numValue" data-ng-required="true" />
I've always used the following mask input plugin in my ASP.Net applications:
http://digitalbush.com/projects/masked-input-plugin/
Unfortunately, this doesn't play well with MVC unobtrusive validation. Validation fires on every keyup which is annoying. Plus, a regex attribute always fails when the input loses focus because it reads the mask as the actual user input before the mask control clears it.
Anybody come across a masked textbox solution that plays well with MVC validation?
Sir you can use Bootstrap placeholder for showing mask Link for example
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">#</span>
<input type="text" class="form-control" placeholder="Username" aria-describedby="basic-addon1">
</div>
I am using the MvcContrib Grid to display a table on the page. I am using a custom column to produce a checkbox on the table so that the user can select multiple rows and submit the form.
I don't want the form to submit unless at least one checkbox has been selected. I could easily write this Javascript myself to enforce the validation, but I wanted to know how I could fit it in with the unobtrusive library supplied with MVC3.
I imagine I just need to set my inputs with the proper classes and attributes and then the scripts (validate and validate.unobtrusive) on the page should pick them up and mark them as needing validation, but I haven't been able to get the right combination thus far.
Here is the input that I am currently generating:
<input type="checkbox"
name="foo"
value="#item.foo"
class="input-validation-error"
data-val-required="Please select an option."
data-val="true" />
Try setting the data-val attributes on the item, then you have to tell jQuery you have new content to re-parse the form via something like:
$.validator.unobtrusive.parse($('#yourForm'));
where form is of course a reference to your form element.
There is also this great posting and jQuery has a few internal adapters you can call:
from http://www.devtrends.co.uk/blog/the-complete-guide-to-validation-in-asp.net-mvc-3-part-2
jQuery.validator.unobtrusive.adapters.addSingleVal("notequalto", "otherproperty", "mynotequaltofunction")
From my experience, a commonly overlooked mistake with displaying client-side validation is putting a Html.ValidationMessageFor(lambda) on the page.
Without that, no client-side validation will fire to prevent the form submit and/or display the message that is generated using annotations on the client-side.
Hope this helps.
<div class="editor-field">
<input class="text-box single-line"
data-val="true" data-val-number="The field Qty Available must be a number."
data-val-range="The field Qty Available must be between 0 and 120."
data-val-range-max="120" data-val-range-min="0"
data-val-required="The Qty Available field is required."
id="QtyOnHand" name="QtyOnHand" type="text" value="12" />
<span class="field-validation-valid" data-valmsg-for="QtyOnHand"
data-valmsg-replace="true"></span>
</div>
The tie-in between the data model annotations and the data-val-* attributes should be clear after reading the above code, but it's where the client side validation ties in might not be so obvious. Open the \Scripts\jquery.validate.unobtrusive.js file and search for "data-val". Right away you'll see that the JavaScript uses the data-val-, input- and field-* CSS classes to display/hide validation messages on the client.
The above is taken from this great article, which you might want to read in full.
i have a form with 2 buttons let say A & B.
The required fields are depending on the button pressed.
Im using actually a DataBinder allowing me to specify requiredFields but for all actions.
How can i customize the required fields that will be depending on the button pressed ?
Thanks in advance
If you use <input type="submit" name="button1" value="Click me!" /> you can check for that button1 value in your form and then use different validation rules within your validator. You just have to extend your binding model according to these button names and to give your two buttons different names. Note that this doesn't work with <button type="submit"> in most IE versions and therefor input[type=submit] is the better choice here :-)