how to validate the dropdownlist box values on submit

Posted by kumar on Stack Overflow See other posts from Stack Overflow or by kumar
Published on 2010-06-06T18:48:57Z Indexed on 2010/06/06 18:52 UTC
Read the original article Hit count: 222

Filed under:

Hello friends,

I have validate_excpt on Form Before Submit I am doing this..

on the View I have two dropdown listboxes I am using On Submit I need to check.. If I selet ResolutionCode I need to validat ReasonCode Dropdownlist that It should select if not Pelase select ReasonCode I should Dispaly?

Do I need to do this on Submit ButtonClick? or Can I do it on Validate_excpt? Can anybody help me out?

<label for="ResolutionCode">
            Resolution:
            <span>
           <%=Html.DropDownListFor(model => model.ResolutionCode, new SelectList(Model.LookupCodes["C_EXCPT_RESL"], "Key", "Value"))%>
            </span>
        </label>
         <label for="ReasonCode">
            Reason:
           <span><%=Html.DropDownListFor(model => model.ReasonCode, new SelectList(Model.LookupCodes["C_EXCPT_RSN"], "Key", "Value"))%></span>
        </label>

function validate_excpt(formData, jqForm, options) {
            var form = jqForm[0];
            return true;
        }
        // post-submit callback 
        function showResponse(responseText, statusText, xhr, $form) {

            if (responseText[0].substring(0, 16) != "System.Exception") {
                $('#error-msg-ID span:last').html('<strong>Update successful.</strong>');
            } else {
                $('#error-msg-ID span:last').html('<strong>Update failed.</strong> ' + responseText[0].substring(0, 48));
            }
            $('#error-msg-ID').removeClass('hide');
        }

        $('#exc-').ajaxForm({
            target: '#error-msg-ID',
            beforeSubmit: validate_excpt,
            success: showResponse,
            dataType: 'json'
        });

© Stack Overflow or respective owner

Related posts about jQuery