简体   繁体   中英

javascript validation value from one cshtml page to check other cshtml page?

I'm want to validate value of name from Create.cshtml and AddUser.cshtml page. working in mvc application

in create.cshtml

<div id="tab3" class="tab_content">

@Html.TextBoxFor(x => x.FirstTripStartTime, new { id = "minStartTime", @class = "smallTxtEntry3" })&nbsp;(HH:MM:SS)

</div>

in adduser.cshtml

<div>
  <td valign="top" class="nd_nor_ftd">Start Time<span class="mand">*</span></td>
                    <td>
                        @Html.TextBoxFor(x => x.StartTime, new { @class = "smallTxtEntry3" })&nbsp;(HH:MM:SS)
                    </td>
</div>

How do I compare and show alert if these two values are same

2nd page is in tabular for actually after 1st gets filled.

  <div id="tab4" class="tab_content">
   <div class="buttonDiv">
      <input type="button" class="button addButton" name="AddUser" id="AddUser" value="Add Useronclick="OpenAddDialogWindow(GoodReceiptParameterCss, '/User/GetPartialView?name=User&mode=add', 'gridVariableFrequencies');" /><br />
       <span>Add Frequency</span>

As you are talking about different pages, you can share state and values between them in*at least* 2 ways:

  1. Save data in DB from one page and read from another (not so good, as need a request)
  2. Save in local storage a value from one page and read it from another page (definitely better)

For easy data save/read on client side can have look on: amplify.js .

您可以使用MVC Session对象来持久保存服务器端数据(无需数据库,或依赖客户端存储)并检查客户端或服务器端的值。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM