I've recently started using KnockOut, so I'm very new to this.
I have completed every tutorial on their site, yet can't get this specific thing to work.
I have to arrays, on the left being all the items, on the right being the items you've selected.
Once you click on the item (left table), it should .push to the right table
ViewModel:
var orderedItemsTable = $("form.orderedDataWithoutBatch")
var viewModel = {
//right side
orderedItems: ko.observableArray(),
//Left side
items: ko.observableArray(),
sortColumn: ko.observable(),
total: ko.observable(),
}
request.done(function (data) {
item.addItem = function () {
alert("item clicked, materiaal id: " + this.MateriaalId);//works
alert(this.MateriaalDescription);//works
viewModel.orderedItems.push(this);//doesn't 'work'
}
viewModel.items.push(item);//unrelated to this context
}
I'm assuming it's either in this code here, or I'm not showing it correctly in my html (because I'm not getting any console errors)
HTML (right side)
<form id="OrderedItemsWithoutBatch" class="orderedDataWithoutBatch">
<table class="orderFormArticlesTable" style="width: 47%;float: right; font-size: 9pt;">
<thead>
<tr>
<th>SKU</th>
<th>Product</th>
<th style="width: 15%">Qty</th>
<th></th>
</tr>
</thead>
<tbody data-bind="foreach: orderedItems">
<tr>
<td data-bind="text: MateriaalSku"> </td>
<td data-bind="text: MateriaalDescription"> </td>
<td data-bind="text: MateriaalId"><!-- Quantity--> </td>
<!--<td><input class="orderedQty" style="max-width: 15%" value="1" />[pieces]</td>-->
<td>Remove</td>
</tr>
</tbody>
</table>
I'm not sure I've understood you right, but I'd solve your task this way:
var orderedItemsTable = $("form.orderedDataWithoutBatch")
var viewModel = {
//right side
orderedItems: ko.observableArray(),
//Left side
items: ko.observableArray(),
sortColumn: ko.observable(),
total: ko.observable(),
}
function proscessRequest(item) {
item.addItem = function () {
//alert("item clicked, materiaal id: " + this.MateriaalId);//works
//alert(item.MateriaalDescription);//works
viewModel.orderedItems.push(this);//doesn't 'work'
}
viewModel.items.push(item);//unrelated to this context
}
ko.applyBindings(viewModel);
proscessRequest({MateriaalSku: "M1", MateriaalDescription: "D1", MateriaalId: "1"});
proscessRequest({MateriaalSku: "M2", MateriaalDescription: "D2", MateriaalId: "2"});
proscessRequest({MateriaalSku: "M3", MateriaalDescription: "D3", MateriaalId: "3"});
proscessRequest({MateriaalSku: "M4", MateriaalDescription: "D4", MateriaalId: "4"});
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.2.0/knockout-min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<form id="OrderedItemsWithoutBatch" class="orderedDataWithoutBatch">
<div>Alavilable items:</div>
<div>
<table class="orderFormArticlesTable">
<thead>
<tr>
<th>SKU</th>
<th>Product</th>
<th style="width: 15%">Qty</th>
<th></th>
</tr>
</thead>
<tbody data-bind="foreach: items">
<tr>
<td data-bind="text: MateriaalSku"> </td>
<td data-bind="text: MateriaalDescription"> </td>
<td data-bind="text: MateriaalId"><!-- Quantity--> </td>
<td><div data-bind="click: addItem">Add</div></td>
</tr>
</tbody>
</table>
</div>
<div style="margin-top: 30px;">
<div>Ordered items:</div>
<table class="orderFormArticlesTable">
<thead>
<tr>
<th>SKU</th>
<th>Product</th>
<th style="width: 15%">Qty</th>
<th></th>
</tr>
</thead>
<tbody data-bind="foreach: orderedItems">
<tr>
<td data-bind="text: MateriaalSku"> </td>
<td data-bind="text: MateriaalDescription"> </td>
<td data-bind="text: MateriaalId"><!-- Quantity--> </td>
<td><div data-bind="click: function() { $parent.orderedItems.remove($data); }">Remove</div></td>
</tr>
</tbody>
</table>
</div>
</form>
Note
I've mocked request with "proscessRequest" function called after bindings have been applied.
Related
I populate this table from an API and try to do a multiple lookup filter from one entry separating each entry by a comma.
they load the data correctly but when trying to search it does nothing
Is this code any good or how could I do a multiple search from one input?
View
File ApiControllers.js
<script>
var testApp = angular.module("LogModule", []);
testApp.controller("TransController", function ($scope, $http) {
$http.get('/api/Trans').then(function (response) {
$scope.logTrans = response.data;
$scope.Show = [];
$scope.separator = ""
$scope.buscar = function () {
let search = $scope.separator.split(",");
$scope.Show =
$scope.logTrans
.filter((item) => {
let a = search.map((value) => {
return JSON.stringify(item)
.toUpperCase()
.indexOf(value.toUpperCase()) > -1 ? 1 : 0;
}).reduce((x, y) => x + y);
return a > 0
})
}
$scope.searchInput()
});
});
File html
<!DOCTYPE html>
<html ng-app="LogModule">
<head>
<script src="~/Scripts/angular.js"></script>
<script src="~/Scripts/ApiCotrollers.js"></script>
<link />
</head>
<body>
<h1>Consulta de transacciones</h1>
<div ng-app="LogModule" class="table-responsive" ng-controller="TransController">
<input type="text" ng-model="filter" ng-change="searchInput()" class="form-control" placeholder="Buscar documentos" aria-describedby="basic-addon2 ">
<br>
<table class="table table-bordered table-hover" align="center">
<tr class="active">
<th> Registro</th>
<th> FechaInsert</th>
<th> FechaModificacion</th>
<th>Observaciones</th>
<th> IdIntegracion</th>
<th>Integrado</th>
<th> Error</th>
<th>ObjetoIntegracion</th>
<th> Bodega</th>
</tr>
<tr ng-repeat=" p in Show track by $index">
<td class="success"> {{p.Registro}}</td>
<td class="success"> {{p.FechaInsert}} </td>
<td class="success"> {{p.FechaModificacion}} </td>
<td class="danger"> {{p.Observaciones}} </td>
<td class="success">{{p.IdIntegracion}} </td>
<td class="success"> {{p.Integrado}} </td>
<td class="success"> {{p.Error}} </td>
<td class="danger"> {{p.ObjetoIntegracion}}</td>
<td class="success">{{p.Bodega}}</td>
</tr>
</table>
</div>
#Scripts.Render("~/bundles/jquery")
#Scripts.Render("~/bundles/bootstrap")
</body>
</html>
I am using knockout Js. I want to show the table row with table header when I click another table row in the table. I used this code below. Can anyone help me out?
var ViewModel = function() {
var self = this;
this.client_details = [{
name: 'Jack',
email: 'jack#gmail.io',
phone: '256987',
address: 'US',
dob: '24/01/1975',
taxid: '125'
}, {
name: 'Hari',
email: 'hari#yahoo.com',
phone: '247896',
address: 'chennai',
dob: '02/01/1975',
taxid: '255'
}];
this.datas = [{
name: 'John',
email: 'john#gmail.com',
phone: '58963287'
}, {
name: 'JohnBert',
email: 'bert#gmail.com',
phone: '589625887'
}];
self.seletedRow = ko.observable();
self.goToFolder = function(folder) {
self.seletedRow(folder);
};
};
ko.applyBindings(new ViewModel(self.datas));
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.2/knockout-min.js"></script>
<table width='100%'>
<thead>
<tr>
<th width='25%'>Client Name</th>
<th width='25%'>Email</th>
<th class='Phone' width='15%'>Phone</th>
<th class='Address' width='10%'>Address</th>
<th class='dob' width='15%'>DOB</th>
<th class='tax' width='15%'>Tax ID</th>
</tr>
</thead>
<tbody data-bind="foreach: client_details">
<tr class="table_row">
<td data-bind="text: name,click: $root.goToFolder"></td>
<td data-bind="text: email"></td>
<td data-bind="text: phone"></td>
<td data-bind="text: address"></td>
<td data-bind="text: dob"></td>
<td data-bind="text: taxid"></td>
</tr>
</tbody>
</table>
<table data-bind="with: seletedRow">
<thead>
<tr>
<th width='25%'>User Name</th>
<th width='25%'>Email</th>
<th class='Phone' width='15%'>Phone</th>
</tr>
</thead>
<tbody data-bind="foreach: datas">
<tr>
<td data-bind="text: name"></td>
<td data-bind="text: email"></td>
<td data-bind="text: phone"></td>
</tr>
</tbody>
</table>
Can anyone help me to get the table row data using knockout?
The with binding creates a new binding context. Your second <table> therefore looks for the name, email and phone properties inside the currently selected client.
If you just want to show/hide the second table based on if there's a selection, you can use the if binding.
If you want to perform any filters/logic on data based on the row that's selected, you can use a computed.
Note that I've also moved your click binding to the <tr>, so you can click anywhere in the row.
var ViewModel = function() {
var self = this;
this.client_details = [{
name: 'Jack',
email: 'jack#gmail.io',
phone: '256987',
address: 'US',
dob: '24/01/1975',
taxid: '125'
}, {
name: 'Hari',
email: 'hari#yahoo.com',
phone: '247896',
address: 'chennai',
dob: '02/01/1975',
taxid: '255'
}];
this.datas = [{
name: 'John',
email: 'john#gmail.com',
phone: '58963287'
}, {
name: 'JohnBert',
email: 'bert#gmail.com',
phone: '589625887'
}];
self.selectedRow = ko.observable();
self.goToFolder = function(folder) {
self.selectedRow(folder);
};
};
ko.applyBindings(new ViewModel(self.datas));
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.2/knockout-min.js"></script>
<table width='100%'>
<thead>
<tr>
<th width='25%'>Client Name</th>
<th width='25%'>Email</th>
<th class='Phone' width='15%'>Phone</th>
<th class='Address' width='10%'>Address</th>
<th class='dob' width='15%'>DOB</th>
<th class='tax' width='15%'>Tax ID</th>
</tr>
</thead>
<tbody data-bind="foreach: client_details">
<tr class="table_row" data-bind="click: $root.goToFolder">
<td data-bind="text: name"></td>
<td data-bind="text: email"></td>
<td data-bind="text: phone"></td>
<td data-bind="text: address"></td>
<td data-bind="text: dob"></td>
<td data-bind="text: taxid"></td>
</tr>
</tbody>
</table>
<table data-bind="if: selectedRow">
<thead>
<tr>
<th width='25%'>User Name</th>
<th width='25%'>Email</th>
<th class='Phone' width='15%'>Phone</th>
</tr>
</thead>
<tbody data-bind="foreach: datas">
<tr>
<td data-bind="text: name"></td>
<td data-bind="text: email"></td>
<td data-bind="text: phone"></td>
</tr>
</tbody>
</table>
I am checking two check boxes in first table those records are adding in second table this is fine. But if unchecked record removing as improper way, how can I remove exact row I unchecked.
var app = angular.module('myApp',[]);
app.controller("homeCtrl", function($scope) {
$scope.items = [{
itemID: 'BR063',
itemValue: 'sagsfgjkfdsffsdfsd'
}, {
itemID: 'BR06417',
itemValue: '1231231231123'
}];
$scope.selectedItems = [];
$scope.addRec = function(result, i){
if(result == true){
$scope.selectedItems.push($scope.items[i-1]);
}
else{
$scope.selectedItems.splice($scope.items[i],1);
}
}
});
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular-route.js"></script>
<div ng-app = 'myApp' ng-controller="homeCtrl">
<h1>Select Rows</h1>
<table style="width:50%" class="table-responsive table-bordered ">
<tr>
<th class="text-center">Index</th>
<th class="text-center">Item ID</th>
<th class="text-center">Item Values</th>
<th class="text-center">Select</th>
</tr>
<tr ng-repeat="x in items">
<td class="text-center">{{$index+1}}</td>
<td class="text-center">{{x.itemID}}</td>
<td class="text-center">{{x.itemValue}}</td>
<td class="text-center"><input type="checkbox" ng-model="itsVal" ng-change = "addRec(itsVal, $index+1)";/></td>
</tr>
</table>
<h1>Selected Rows</h1>
<table style="width:50%" class="table-responsive table-bordered ">
<tr>
<th class="text-center">Index</th>
<th class="text-center">Item ID</th>
<th class="text-center">Item Values</th>
<th class="text-center">Select</th>
</tr>
<tr ng-repeat="x in selectedItems">
<td class="text-center">{{$index+1}}</td>
<td class="text-center">{{x.itemID}}</td>
<td class="text-center">{{x.itemValue}}</td>
<td class="text-center"><input type="checkbox" /></td>
</tr>
</table>
<div>
You just need to do $scope.selectedItems.splice(i-1, 1); in the else block. Also since result is a boolean value you can simply use if (result) in the condition:
var app = angular.module('myApp', []);
app.controller("homeCtrl", function($scope) {
$scope.items = [{
itemID: 'BR063',
itemValue: 'sagsfgjkfdsffsdfsd'
}, {
itemID: 'BR06417',
itemValue: '1231231231123'
}];
$scope.selectedItems = [];
$scope.addRec = function(result, i) {
if (result) {
$scope.selectedItems.push($scope.items[i - 1]);
} else {
$scope.selectedItems.splice(i-1, 1);
}
}
});
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular-route.js"></script>
<div ng-app='myApp' ng-controller="homeCtrl">
<h1>Select Rows</h1>
<table style="width:50%" class="table-responsive table-bordered ">
<tr>
<th class="text-center">Index</th>
<th class="text-center">Item ID</th>
<th class="text-center">Item Values</th>
<th class="text-center">Select</th>
</tr>
<tr ng-repeat="x in items">
<td class="text-center">{{$index+1}}</td>
<td class="text-center">{{x.itemID}}</td>
<td class="text-center">{{x.itemValue}}</td>
<td class="text-center"><input type="checkbox" ng-model="itsVal" ng-change="addRec(itsVal, $index+1)" ;/></td>
</tr>
</table>
<h1>Selected Rows</h1>
<table style="width:50%" class="table-responsive table-bordered ">
<tr>
<th class="text-center">Index</th>
<th class="text-center">Item ID</th>
<th class="text-center">Item Values</th>
<th class="text-center">Select</th>
</tr>
<tr ng-repeat="x in selectedItems">
<td class="text-center">{{$index+1}}</td>
<td class="text-center">{{x.itemID}}</td>
<td class="text-center">{{x.itemValue}}</td>
<td class="text-center"><input type="checkbox" /></td>
</tr>
</table>
<div>
The issue here is that you are trying to remove via index rather than using the id. Have made some changes in the addRec function and the line in html invoking it. Please go through them once:
var app = angular.module('myApp',[]);
app.controller("homeCtrl", function($scope) {
$scope.items = [{
itemID: 'BR063',
itemValue: 'sagsfgjkfdsffsdfsd'
}, {
itemID: 'BR06417',
itemValue: '1231231231123'
}];
$scope.selectedItems = [];
$scope.addRec = function(result, i,itemId){
if(result == true){
$scope.selectedItems.push($scope.items[i-1]);
}
else{
var index=0;
var isMatched = false;
angular.forEach($scope.selectedItems,function(item) {
if(isMatched === false) {
if(item.itemID === itemId) {
isMatched = true;
}
else {
index++;
}
}
});
$scope.selectedItems.splice(index,1);
}
}
});
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular-route.js"></script>
<div ng-app = 'myApp' ng-controller="homeCtrl">
<h1>Select Rows</h1>
<table style="width:50%" class="table-responsive table-bordered ">
<tr>
<th class="text-center">Index</th>
<th class="text-center">Item ID</th>
<th class="text-center">Item Values</th>
<th class="text-center">Select</th>
</tr>
<tr ng-repeat="x in items track by x.itemID">
<td class="text-center">{{$index+1}}</td>
<td class="text-center">{{x.itemID}}</td>
<td class="text-center">{{x.itemValue}}</td>
<td class="text-center"><input type="checkbox" ng-model="itsVal" ng-change = "addRec(itsVal, $index+1,x.itemID)";/></td>
</tr>
</table>
<h1>Selected Rows</h1>
<table style="width:50%" class="table-responsive table-bordered ">
<tr>
<th class="text-center">Index</th>
<th class="text-center">Item ID</th>
<th class="text-center">Item Values</th>
<th class="text-center">Select</th>
</tr>
<tr ng-repeat="x in selectedItems track by x.itemID">
<td class="text-center">{{$index+1}}</td>
<td class="text-center">{{x.itemID}}</td>
<td class="text-center">{{x.itemValue}}</td>
<td class="text-center"><input type="checkbox" /></td>
</tr>
</table>
<div>
Just create a directive as you don't need to repeat the code for table rendering, and use a filter to sort out the selected rows!
var app = angular.module('myApp', []);
app.directive("tableRenderer", function(){
return {
restrict: 'E',
template: `
<table style="width:50%" class="table-responsive table-bordered ">
<tr>
<th class="text-center">Index</th>
<th class="text-center">Item ID</th>
<th class="text-center">Item Values</th>
<th class="text-center">Select</th>
</tr>
<tr ng-repeat="x in list | filter:filter">
<td class="text-center">{{$index+1}}</td>
<td class="text-center">{{x.itemID}}</td>
<td class="text-center">{{x.itemValue}}</td>
<td class="text-center"><input type="checkbox" ng-model="x.selected" ;/></td>
</tr>
</table>
`,
scope: {
list: '=',
filter: '='
},
link: function(scope, elem, attr) {
}
}
})
app.controller("homeCtrl", function($scope) {
$scope.items = [{
itemID: 'BR063',
itemValue: 'sagsfgjkfdsffsdfsd',
selected: false
}, {
itemID: 'BR06417',
itemValue: '1231231231123',
selected: false
}];
});
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular-route.js"></script>
<div ng-app='myApp' ng-controller="homeCtrl">
<h1>Select Rows</h1>
<table-renderer list="items"></table-renderer>
<h1>Selected Rows</h1>
<table-renderer list="items" filter="{selected: true}"></table-renderer>
<div>
I have a JSON object where EntityCode, EntityName, TagName, and TaskName (from TagList) are to be table column headers.
StatusFlagName in TaskRecordList is then to be in a nested row under it's related TaskName. The StatusFlagName values should be directly below the TaskName.
How do I get this working? The StatusFlagName will not display.
var ViewModel = function() {
this.taskRecords = ko.observableArray([
{
EntityCode: "name",
EntityName: "name desc23",
TagName: "L1",
TaskList: [
{
TaskName: "TaskABC",
TaskRecordList: [
{
StatusFlagName: "OK"
},
{
StatusFlagName: "TEST"
}
]
},
{
TaskName: "TaskDEF",
TaskRecordList: [
{
StatusFlagName: "Error"
}
]
}
]
}
]);
};
ko.applyBindings(new ViewModel());
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.2/knockout-min.js"></script>
<table class="table table-bordered">
<tbody data-bind="foreach: taskRecords">
<tr>
<td data-bind="text: EntityCode"></td>
<td data-bind="text: EntityName"></td>
<td data-bind="text: TagName"></td>
<td></td>
<!--ko foreach: TaskList-->
<td data-bind="text: TaskName">
<table>
<tbody>
<!--ko foreach: TaskRecordList-->
<tr>
<td data-bind="text: StatusFlagName"></td>
</tr>
<!--/ko-->
</tbody>
</table>
</td>
<!--/ko-->
</tr>
</tbody>
</table>
When you use <td data-bind="text: TaskName"> knockout will replace whatever you have inside this tag with the value of TaskName as a text that's why your last nested table is being replaced with TaskName value.
You can add a div or span for TaskName something like below :
<table class="table table-bordered">
<tbody data-bind="foreach: taskRecords">
<tr>
<td data-bind="text: EntityCode"></td>
<td data-bind="text: EntityName"></td>
<td data-bind="text: TagName"></td>
<td></td>
<!--ko foreach: TaskList-->
<td>
<div data-bind="text: TaskName"></div>
<table>
<tbody>
<!--ko foreach: TaskRecordList-->
<tr>
<td data-bind="text: StatusFlagName"></td>
</tr>
<!--/ko-->
</tbody>
</table>
</td>
<!--/ko-->
</tr>
</tbody>
</table>
My problem is that in my registration form when it has error message and the user tries to changed tab and back again to registration the error message are still there what should I do to be able to remove the error message when I changed the tabs and when I click again the registration link?
<script src="http://code.jquery.com/jquery-1.8.1.js"></script>
<script>
$(function() {
var tabContainers = $('section.tabs > article');
tabContainers.hide().filter('#login').show();
$('.ultabs a').click(function () {
tabContainers.hide();
tabContainers.filter(this.hash).show();
$('.ultabs a').removeClass('selected');
$(this).addClass('selected');
return false;
});
});
function check_email() {
var email=$("#textEmail").val();
$.ajax(
{
type:"POST",
url:"register.php",
data: {
'email': email
},
success:function(msg) {
$("#checkEmail").html(msg);
}
});
return false;
}
function check_password() {
var pass=$("#textPassword").val();
$.ajax(
{
type:"POST",
url:"register.php",
data: {
'pass': pass
},
success:function(msg) {
$("#checkPassword").html(msg);
}
});
return false;
}
</script>
<nav id="siteNav">
<h1>Navigation</h1>
<ul class="ultabs">
<li>Login</li>
<li>Register</li>
</ul>
</nav>
<section id="siteContent" class="tabs">
<h1>Section</h1>
<article id="login">
<h1>Login</h1>
<table>
<tr>
<td class="message" colspan="2"></td>
</tr>
<tr>
<td>E-mail:</td><td><input type="email"></td>
</tr>
<tr>
<td class="message" colspan="2"></td>
</tr>
<tr>
<td>Password:</td><td><input type="password"></td>
</tr>
<tr>
<td colspan="2"><input type="button"></td>
</tr>
</table>
</article>
<article id="register">
<h1>Register</h1>
<table>
<tr>
<td class="message" colspan="2"></td>
</tr>
<tr>
<td>Name:</td><td><input type="text"></td>
</tr>
<tr>
<td id="checkEmail" class="message" colspan="2"></td>
</tr>
<tr>
<td>E-mail:</td><td><input id="textEmail" type="email" onblur="return check_email()"></td>
</tr>
<tr>
<td id="checkPassword" class="message" colspan="2"></td>
</tr>
<tr>
<td>Password:</td><td><input id="textPassword" type="password" onblur="return check_password()"></td>
</tr>
<tr>
<td class="message" colspan="2"></td>
</tr>
<tr>
<td>Re-type:</td><td><input type="password"></td>
</tr>
<tr>
<td colspan="2"><input type="button"></td>
</tr>
</table>
</article>
</section>
I would suggest you use a validator plugin like the one provided by Bassistance - http://bassistance.de/jquery-plugins/jquery-plugin-validation/ . It will handle the error messages without you getting into the nitty gritty of validation....
You can clear the td on change of the tab
$('.ultabs a').click(function () {
$('.message').html('');
// the rest of your code
});