jQWidgets Forums

jQuery UI Widgets Forums Lists ComboBox jqx combobox validator

This topic contains 4 replies, has 3 voices, and was last updated by  robrichard 11 years, 8 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • jqx combobox validator #13938

    okasha
    Participant

    i am using the following code to validate a form with a combo box the problem is that it display the validation message even when i choose a value from the combo box

    $(“#user_form”).jqxValidator({
    rules: [
    {input: ‘#user_email’, message: ‘من فضلك ادخل البريد الالكتروني’, action: ‘keyup, blur’, rule: ‘required’ },
    {input: ‘#user_email’, message: ‘من فضللك ادخل بريد الكترونى صحيح’, action: ‘keyup, blur’, rule: ’email’ },
    {input: ‘#user_gender’, message: ‘من فضلك اختر النوع’, action: ‘select’, rule: function(input){
    alert(input.val());
    if(input.val()==””){
    return false;
    }
    return true;

    } }

    ]
    });

     

    can you help me plase

     

    jqx combobox validator #13962

    Dimitar
    Participant

    Hello okasha,

    jqxComboBox has its own method for getting or setting the value – ‘val’. Thus, your code should look like this:

    $(“#user_form”).jqxValidator({
    rules: [
    {input: '#user_email', message: 'من فضلك ادخل البريد الالكتروني', action: 'keyup, blur', rule: 'required' },
    {input: '#user_email', message: 'من فضللك ادخل بريد الكترونى صحيح', action: 'keyup, blur', rule: 'email' },
    {input: '#user_gender', message: 'من فضلك اختر النوع', action: 'select', rule: function(input){
    var val = $("#user_gender").jqxComboBox('val');
    alert(val);
    if(val==""){
    return false;
    }
    return true;
    } }
    ]
    });

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    jqx combobox validator #13964

    okasha
    Participant

    hello mr dimitar

    thank you very much for your help
    it works for me now

    thanks
    okasha

    jqx combobox validator #25272

    robrichard
    Member

    Is it for sure that this works? I implemented the same sort of code, and when I manually type something in the combobox, it says that it is still required. I tried this using both 2.8.3 and 2.9.3

    Here are my rules:

    { input: '#Vendor', message: 'A vendor is required - please select or enter a vendor', action: 'keyup, blur', rule: 'required' },
    { input: '#Vendor', message: 'A vendor is required - please select or enter a vendor', action: 'select', rule: function(input){if($("#Vendor").jqxComboBox('val') == "") {alert("false"); return false;} else {alert("true"); return true};} }

    Here is the combobox definition:

    $("#Vendor").jqxComboBox({source: dataAdapter1, displayMember: "Vendor", valueMember: "Vendor", width: 200, height: 25, theme: 'orion', searchMode: 'containsignorecase', autoComplete: true });

    And here is the html:

    <div id="Vendor" class="text" />
    jqx combobox validator #25273

    robrichard
    Member

    Ugh – on a whim I decided to remove the first rule, and wouldn’t you know it, it works. The trick is to use ONLY the function. Ummm, why not just modify the validator code to accommodate this very common scenario instead of requiring the developers to jump through hoops?

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.