0

enter image description here

here have two fields

1)Fields_1

2)Fileds_2

here i want to validate Field_2 < Filed_1 (less than )

how i do this in magenot 2???

Field_2 Tag

  <div class="field">
                            <label class="label"><?php /* @escapeNotVerified */echo __('Current quote amount') ?>:</label>
                            <div class="control">
                                <input type="text"
                                       class='input-text'
                                       readonly='readonly'
                                       value="<?php  $sellerlowestquoteDetails=$quoteHelper->getSellerLowestQuote($quote->getId());
                                       $seller_detail='';
                                       //echo count($sellerlowestquoteDetails);

                                       if(count($sellerlowestquoteDetails)>0){
                                           foreach($sellerlowestquoteDetails as $sellerlowestquoteDetail){
                                               $seller_detail=$sellerlowestquoteDetail;
                                           }
                                       }
                                       if(count($sellerlowestquoteDetails)>0) {
                                           echo $seller_detail['seller_quote_price'];
                                       }
                                       else{
                                           echo "N/A";
                                       }

                                       //print_r($seller_detail['seller_quote_price']);/* @escapeNotVerified */ //$tt=$quoteHelper->getSellerLowestQuote($quote->getId());


                                       ?>"
                                       name='customer_iiid'
                                />
                            </div>
                        </div>
 <div class="field">
                                <?php $price = number_format($sellerquote->getSellerQuotePrice(), 2);?>
                                <label class="label"><?php /* @escapeNotVerified */echo __('Your Quote Price')." (".$currencySymbol.")" ?>:</label>
                                <div class="control">
                                    <input type="text"
                                        class='input-text required-entry validate-number validate-greater-than-zero'
                                         <?php echo ($priceDisabled1)?"readonly='readonly'":''?>
                                        value="<?php /* @escapeNotVerified */echo $price ?>"
                                        name='seller_quote_price'
                                    />
                                    <small>Give your quote price.</small>
                                    <input type="hidden"
                                         readonly='readonly'
                                        value="<?php /* @escapeNotVerified */echo $price ?>"
                                        name='quote_price'
                                    />
                                </div>
                            </div>
<div class="buttons-set">
            <p class="back-link">
                <a href="javascript:;"
                    onclick="javascript: window.history.back();"
                    class="left"
                >&laquo; <?php /* @escapeNotVerified */echo __('Back') ?></a>
            </p>
        </div>
        <?php if (!$disabled) : ?>
        <?php    $block->getsellerupdateCollection($sellerquote->getQuoteId(),$quote->getCustomerId())

        ?>
            <button class="button wk-mp-qs-btn"
                title="<?php /* @escapeNotVerified */echo __('Update') ?>"
                type="submit"
                id="save_butn"
            >
                <span><span><?php /* @escapeNotVerified */echo __('Update') ?></span></span>
            </button>
        <?php else: ?>
            <h2><?php /* @escapeNotVerified */echo __('View Quote') ?></h2>
        <?php endif; ?>
    </div>
<?php
    }
} else {
    echo "<h2 class='wk_new_msg'>".__("To BECOME SELLER PLEASE CONTACT TO ADMIN.")."</h2>";
}?>
<?php
$formData = [
    'quoteForm'     =>  '#form-quote',
    'saveButton'    =>  '#save_butn'
];
$serializedFormData = $this->helper('Magento\Framework\Json\Helper\Data')->jsonEncode($formData);
?>
<script type="text/x-magento-init">
    {
        "*": {
            "WkMpQuotesystem": <?php /* @noEscape */ echo $serializedFormData; ?>
        }
    }
</script>
6
  • where are you making these fields ?
    – ASQ
    Apr 15, 2019 at 13:13
  • custom module bro... Apr 15, 2019 at 13:13
  • can you share your form code of these fields
    – ASQ
    Apr 15, 2019 at 13:27
  • ur asking full .phtml file Apr 15, 2019 at 13:29
  • yes share your form code
    – ASQ
    Apr 15, 2019 at 13:35

1 Answer 1

2
<input type = "text" id ="price1" ?>
<input type = "text" id ="price2" ?>
<div id = "error"></div>
<script>
    $(document).ready(function(){

        $("#price2").keypress(function(){

        var price1 = document.getElementById("price1").value;
        var price2 = document.getElementById("price2").value;
        if(parseInt(price2) > parseInt(price1) ){
        //alert("price 2 is greater then price1");
        document.getElementById('error').innerHTML ="price 2 is greater then price1" ;

        }
      })
    });
</script>

check if it will solve your problem

2
  • this is not working.... Apr 19, 2019 at 5:22
  • it's validating but when i click on submit button it's updating ......values Apr 19, 2019 at 5:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.