In modal popup - Server side validation work but popup is closed after message showing.
how to solve this.
and in jquery - i entered numeric value in text box and compare both the text box value, but not working
In modal popup - Server side validation work but popup is closed after message showing.
how to solve this.
and in jquery - i entered numeric value in text box and compare both the text box value, but not working
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sachin SinghPosted Jan 8, 2024, 8:25 AM
On your Ajax call, you must be getting the success message from server-side code on Ajax success, based on that close the modal,
if not getting anything from server then modify your server code to return some message.
Naimish MakwanaPosted Jan 8, 2024, 7:37 AM
I see that you’re using Bootstrap’s modal component. If you want to prevent the modal from closing when server-side validation fails, you can stop the form submission and show the validation errors in the modal.
Here’s a sample approach:
In this code, replace
#yourFormwith the id of your form, and replace the...invar isValid = ...;with your validation logic. TheShowPopupfunction is used to display the modal with the validation error messages.For the jQuery issue, you can compare numeric values in text boxes by parsing them as integers first. Here’s a sample code snippet:
In this code, replace
.check,.number1, and.number2with the appropriate selectors for your elements. TheparseIntfunction is used to convert the text box values to integers for comparison.Remember to replace the class names and variable names with the ones you’re using in your project. If you’re still facing issues, please provide more details or share the relevant parts of your code.
rupesh gourPosted Jan 8, 2024, 7:33 AM
my popup is this
Naimish MakwanaPosted Jan 8, 2024, 7:29 AM
For the modal popup issue, you can prevent the modal from closing if there are validation errors. Here’s a general approach:
OkControlIDor anOnOkScripton the ModalPopupExtender. This will ensure that the ModalPopupExtender doesn’t close automatically when the “OK” button is clicked1.Here’s a sample jQuery code snippet for your reference:
This code prevents the modal from closing but it doesn’t show any of the errors4.
For the jQuery issue, you can compare numeric values in text boxes by parsing them as integers first. Here’s a sample code snippet:
This code compares two numbers correctly in jQuery5. Make sure you’re not comparing string representations of numbers, as that could lead to unexpected results.
Remember to replace the class names and variable names with the ones you’re using in your project. If you’re still facing issues, please provide more details or share the relevant parts of your code.
Thanks