RadhaKrishnaKiJaya
asked on
Make a div invisible
Hi Experts,
I have the following code. Before @Html.ValidationSummary() I want to put a check, if 'InvaliFileFormat' div is visible then make it invisible.
Thanks in advance!
I have the following code. Before @Html.ValidationSummary() I want to put a check, if 'InvaliFileFormat' div is visible then make it invisible.
@using (Html.BeginFormAntiForgeryPost("/Contact", FormMethod.Post, new { @enctype = "multipart/form-data" }))
{
@Html.ValidationSummary()
if (Model.UploadIssueMessages != null)
{
<div class="validation-summary-errors" style="display:normal;margin-bottom: 0px;" id="InvaliFileFormat">
<ul>
<li>@Model.UploadIssueMessages</li>
</ul>
</div>
}}
Thanks in advance!
ASKER
Thank you very much for your reply! Actually file format is checked in server side. But the other field are required fields and the validation is done in client side. When the client side validation failed and any message is in display, I want the server side message to be invisible, if it is visible.
Thank you again.
Thank you again.
I want the server side message to be invisible, if it is visible.This does not make sense.
What do you mean by server side message - do you mean the message that is generated by the server?
Are you saying that when the page validates the server might put a message on the page - and later you want to remove that message in the client based on some event in the client?
Can you be a bit more specific - what needs to happen on the client for the server side GENERATED message to be hidden?
ASKER
Thank you for your reply. In the attached picture, Comment is validated at client side and after you choose a file, that extension is validated at server side. Because I have a set of extensions available in the database table. So If the comment is entered and file extension is wrong then I get the first message. But after the first message is displayed and suppose I took away the comment and submit the form then I need only the second message. Somehow want to make the first message invisible.
Thanks for trying to help me!
img2.png
Thanks for trying to help me!
img2.png
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Julian,
Thank you for trying to help me! In our project we have different file extension checks at different places. That is why we kept all the file formats in a table. But as per your suggestion I will try it for displaying the message and let you know.
Thanks again.
Thank you for trying to help me! In our project we have different file extension checks at different places. That is why we kept all the file formats in a table. But as per your suggestion I will try it for displaying the message and let you know.
Thanks again.
This is something that should be done in JavaScript.
Is your code above part of an AJAX call - or just part of the normal page render?
If it is the end point of an AJAX call then you should put the hide / show in JavaScript on your page.
If it is part of the page render then you should have enough information at render time to determine if the file format is invalid and at that point decide to either render the message or not.