jQuery validation of controls - javascript

I am looking at validation of some text boxes for things like required,
minlength, max length, email etc... I am able to get examples that work fine on submit button on page. I want to do this validation on a button click which will only raise a Ajax request and not submit of page.
On the Internet all the samples found was with a submit button. Is there an
easy way to change this code a little bit to make it work for non submit button click or any
new jQuery or Java plugin to do the same?
I am using the jquery.validation.js for now. This works with submit buttons.
Any kind of help with suggestion or help is appreciated.

The jQuery validator plugin already handles this. Just tweak some of the options in the validate method.
As quoted in the documentation for the onfocusout option:
Validate elements (except checkboxes/radio buttons) on blur. If nothing is entered, all rules are skipped, except when the field was already marked as invalid.
Code Example:
$("#form").validate({
onfocusout: false
});
That's just one of a few dozen options you can configure. You can see the full list of options for the validate method here:
http://docs.jquery.com/Plugins/Validation/validate#options

Related

Angular Fomrly and Modals - unable to update validation of form after modal input

I have created a modal that works in moving the model from the modal to the form, however if the field has required: true, the form will not validate if the field is touched but then checked in the modal.
I have a working JSBin showing the issue.
As you can see from the example, I have tried various things to force the field to valid without any luck.
Any help would be appreciated.
No idea why you are moving the model to a modal and then back, it seems to serve little purpose. I have found cases when validation doesn't always work right, this seems to be one of them. You have two options. Use an expression property to check a separate flag you set when you select the field to change required to false or simply set a flag and use that to check validation manually.

Ext JS Search button which is attached to form

So basically I wanted to make a thing like this. A search button which is disabled. than when somebody enters something in one of the fields of the form I want button to enable itself and if somebody cleans every input up than I want to disable that button back. So my Idea was something like this. Extend the button provided by Ext JS. and somehow when this button is drawn or initialized, attach event of value changed to its upper form's input fields. so basically when somebody changes value of any input, that method attached as a listener will be called and than with help of some logic I can achieve the thing I want. but there is one problem. I don't really see how to do that. I mean I have some guesses but all of them have led me to the dead-end. So can you suggest what can I look at or from where to start ?
You can use formBind to enable/disable button depending on the validity state of the form. Validity of the form fields are checked against the validators set for form fields (like allowBlank: false). See the Example usage here
Another way to validate is to use VTypes
But, for the specific requirement to enable button if user enter values in any one of the fields, you might require custom validators. Sample fiddle here: https://fiddle.sencha.com/#fiddle/5qe

popup screen won't show after submitting a form

I am building a web app with jquery mobile. On one page I have a little form to make a room reservation. I have two input boxes. In these boxes comes the start DateTime and in the other one the end DateTime.
Now what I do is the following, when I click on the input box there comes an popup box where you can insert a DateTime. The plugin is called mobiscroll.
I am opening it like this in my JS.
$('[data-role=page]').live('pageinit', function(event){
$("#DATUM_BEGIN").scroller({ preset: 'datetime',theme: 'jqm', mode: 'mixed',display:'modal'});
$("#DATUM_EINDE").scroller({ preset: 'datetime',theme: 'jqm', mode: 'mixed',display:'modal'});
});
The first time it does is correctly. But If I for example forget to enter the end date and submit my form with the submit button. It shows the error messages on the screen. But whenI then want to enter a date. The popup box won't show.
Does anybody know how I can solve this on a correct way?
EDIT: SOLUTION
Ok I found the solution, you just need to disable the ajax with and it will work.
You can disable your ajax on a form by using the attribute data-ajax=false
You should use
$(page).live('pageinit', function(event){
// Your code
// 'page' is a selector for the jquery mobile page you want to work on
});
instead of:
$(document).ready(function(){});
You can see why here http://jquerymobile.com/demos/1.1.0/docs/api/events.html
I think it might be this problem, but even if it's not, I would work that way, it will avoid several headaches.

Unable to disable a required field in CRM 2011 online

The 'estimatedvalue' attribute of the opportunity entity is marked as being required. I have it on the form, but have marked it as being disabled, both through the Form UI customization, as well as using javascript, but some other javascript is re-enabling the form after I've disabled it.
The best solution I have so far is disabling the attribute from the callback of a timeout: setTimeout("CommonLib.setDisabled('estimatedvalue', true);", 1);. When the field loads, it loads as disabled, then some other js is enabling the field, then the callback from the timeout runs and disables it again, so you see the field go from grayed out, to black, to grayed out.
There are two other attributes that I've disabled and they stay disabled, but the estimatedvalue is the only one that is actually required, so I'm guessing it has something to do with that.
Any ideas as to what is re-enabling the field?
I dont think it has anything to do with the requirement level but #Anwar may be one explanation. Could you double check if some other custom script might be enabling the field?
I just tried following with the task where subject is the required field and it seems to be working fine:
Xrm.Page.ui.controls.get('subject').setDisabled(true);

Input validaton with a function call jquery

I am trying to find the correct jquery plugin to validate a few input elements on my page. I would like to be able to have the validation happen on the fly and if any of the validations fail it will call a function. I have been researching this and I can not find a good example on how to do this or what plugin to use. I ultimately just want to validate a few input fields such as first name, last name, email, phone, etc. and if any of them fail the Submit button is disabled. Any ideas?
Try this one -- looks like it does what you want.
http://bassistance.de/jquery-plugins/jquery-plugin-validation/

Categories

Resources