[eluser]marjune[/eluser]
ei guys, please help i'm a newbie in jquery, inside my dialog i had a two input text and a
submit button, and every time the user click the submit button it will check the the inputs
for validation, the problem is it will validate the input once.
my code:
$(function() {
var error = $(".err"),
topic = $("#topic"),
thread = $("#thread"),
allFields = $([]).add(error);
$dialog = $('.dialog')
.dialog({
autoOpen: false,
title: 'Add New Topic',
height: 290,
width: 600
});
$('.topic').click(function() {
$dialog.dialog('open');
});
function ferror(value, txt){
if(value.val() == ""){
error.addClass('ui-state-error');
displayerror(value + " is required.");
return false;
}
else
return true;
}
function displayerror(e){
error.html(e);
error.fadeOut(1500);
}
$("#post").click(function(){
var inputcheck = true;
allFields.removeClass('ui-state-error');
inputcheck = inputcheck && ferror(topic,"Topic"),
inputcheck = inputcheck && ferror(thread,"Thread");
if(inputcheck){
alert('input ok');
$dialog.dialog('close');
return false;
}
return false;
});
});