TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Hamza Shah
NA
87
22.8k
The system show error message in the same grid at the end (last column
Mar 1 2021 6:00 AM
I've working on a project where I'm importing customers data from .Csv file and then after reading the file load data in a grid (HTML table). I've set some checks on the values if there format are wrong so then it's shows error at the end column of table. Now I Want If a file is not validated, the system should show error messages in the same grid at the end (last column). In this case show a prompt to the user "There is some error in data, please check the last column of the grid for further detail" So how can I do that?
Here I'm loading the data in a grid and validating it.
var
NoOfColumn = FileDataArray[0].length;
$(
"tbody"
).empty();
for
(
var
i = 0; i < FileDataArray.length; i++)
{
var
tr =
"<tr>"
$.each(FileDataArray[i],
function
(i, v) {
tr = tr +
"<td>"
+ v +
"</td>"
;
})
tr = tr +
"</tr>"
;
$(
"tbody"
).append(tr);
}
var
cntrl = $(
"#dialog-ProductLoader-div"
);
cntrl.dialog(
"close"
);
for
(
var
i = 0; i < FileDataArray.length; i++)
{
if
(i != 0) {
for
(
var
j = 0; j < FileDataArray[i].length; j++) {
if
(FileDataArray[i][0] ==
null
&& j == 0)
alert(
"Customer Name is Mandatory"
);
if
(FileDataArray[i][1] ==
null
&& j == 1) {
alert(
"Customer Type Name Input is mandatory"
);
}
if
(FileDataArray[i][2] ==
null
|| FileDataArray[i][2] ==
"No"
&& j == 2) {
FileDataArray[i][2] ==
false
;
}
if
(FileDataArray[i][2] ==
"Yes"
||
"yes"
&& j == 2) {
FileDataArray[i][2] ==
true
;
}
if
(FileDataArray[i][3] ==
null
&& j == 3) {
FileDataArray[i][3] == 0;
}
if
(isNaN(FileDataArray[i][3]) && j == 3) {
alert(
"Credit Limit value must be numeric"
)
}
if
(FileDataArray[i][4] ==
null
&& j == 4) {
FileDataArray[i][4] == 0;
}
if
(isNaN(FileDataArray[i][4]) && j == 4) {
alert(
"Opening Balance value must be numeric"
)
}
if
(FileDataArray[i][5] != (
"Male"
||
"male"
||
"female"
||
"Female"
||
"other"
||
"Other"
||
""
) && j == 5) {
alert(
"Error"
);
}
if
(isDate(FileDataArray[i][6]) && j == 6) {
alert(
"Error"
)
}
if
(isDate(FileDataArray[i][7]) && j == 7) {
alert(
"Error"
)
}
var
mailformat = /^(([^<>()[\]\\.,;:\s@
"]+(\.[^<>()[\]\\.,;:\s@"
]+)*)|(
".+"
))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
if
((!mailformat.test(FileDataArray[i][9]) && j == 9)){
alert(
"Email is invalid"
)
}
}
}
}
And Here is View
<div
class
=
"customertable"
>
<table
class
=
"table table-bordered table-responsive"
>
<thead
class
=
"thead-light"
>
<tr>
</tr>
</thead>
<tbody id=
"loaderBody"
>
</tbody>
</table>
</div>
Reply
Answers (
0
)
How to know what was the requested page and redirect to after login?
Manage Html and Css.