You are on page 1of 3

count=${maxCount};

$("#addRoomSlab").click(function(){
var lastcount=count-1;
var lastdata=$.trim($
("#roomDetail"+lastcount+"roomCount").val());
var lastdatamin=$.trim($
("#roomDetail"+lastcount+"roomName").val());
var lastdesc=$.trim($
("#roomDetail"+lastcount+"comment").val());
if(count>=1&&(lastdata==""||
lastdatamin==""||lastdesc==""))
{
$
("#hotel_form").submit();
}
else {
var slab="<div class='room_slab'
id='room_slab_"+count+"'> " +
"<div class='row'>" +
"<div class='col-md-4'><div
class='form-group'> " +
" <div class='col-md-12'> " +
" <input type='text'
name='roomDetail["+count+"].roomName' placeholder='Room Type'
id='roomDetail"+count+"roomName' " +
" class='comment form-control ui-
wizard-content' > " +
" </div> " +
" </div> </div> " +
" <div class='col-md-2'><div
class='form-group '> " +
" <div class='col-md-12'> " +
" <input type='text'
name='roomDetail["+count+"].roomCount' placeholder='Room Count'
id='roomDetail"+count+"roomCount'" +
" class='comment form-control ui-
wizard-content'> " +
" </div> " +
" </div></div> " +
" <div class='col-md-4'><div
class='form-group'> " +
" <div class='col-md-12'> " +
" <textarea type='text'
name='roomDetail["+count+"].comment' placeholder='Room Descriptions'
id='roomDetail"+count+"comment' " +
" class='comment form-control ui-
wizard-content'/> " +
" </div> " +
" </div></div> "+
" <div class='col-md-2'><div
class='form-group'> " +
" <div id='remove_slab_"+count+"'
onclick='removeCustom0("+count+")' class='btn btn-sm btn-primary' > "+
" <i class='hi hi-remove'></i>Remove
"+
" </div></div> " +
" </div> "+
" </div> " +
" <div class='row'>" +
" <div class='col-md-12'> <div
class='row form-group'> " +
" <label class='col-md-
12'>Bedding</label>" +
" <div class=' col-md-12'> " +
" <label for='example-inline-
radio1' class='radio-inline'> " +
" <input type='radio'
value='single' checked='checked' name='roomDetail["+count+"].roomType'
id='roomDetail"+count+"singleRoom'> Single </label> " +
" <label for='example-inline-
radio1' class='radio-inline'> " +
" <input type='radio'
value='double' name='roomDetail["+count+"].roomType'
id='roomDetail"+count+"doubleRoom'> Double </label> " +
" <label for='example-inline-
radio1' class='radio-inline'> " +
" <input type='radio'
value='twin' name='roomDetail["+count+"].roomType'
id='roomDetail"+count+"twinRoom'> Twin </label> " +
" <label for='example-inline-
radio1' class='radio-inline'> " +
" <input type='radio'
value='triple' name='roomDetail["+count+"].roomType'
id='roomDetail"+count+"suiteRoom'> Triple </label> " +
" </div> </div> </div></div>" +
" </div>"

$("#roomSlab").append(slab);

$
('#roomDetail'+count+'roomName').rules("add", {
required:!0,
maxlength:75,
messages:{
required:'Please
enter this field',
maxlength:'This
field should not be more than 75 character',
}});

$
('#roomDetail'+count+'roomCount').rules("add", {
required:!0,
maxlength:3,
number: true,
messages:{
required:'Please
enter this field',
maxlength:'This
field should not be more than 3 digit',
number: 'Please
enter in number only',
}});
$
('#roomDetail'+count+'comment').rules("add", {
required:!0
,maxlength : 75,
messages:{
required:'This
field is required.',
maxlength:'comment
should not be more than 75 characters',
}
});
count++;
if(count==1)
{
$
("#removeSlab").css("display","inline");
}
if(count==5){
$
("#addRoomSlab").css("display","none");
}

});

$("#removeSlab").click(function(){
removecount=count-1;
$
('#room_slab_'+removecount).remove();
count--;
if(count==4){
$
("#addGroupSlab").css("display","inline-block");
}
if(count==0)
{
$
("#removeSlab").css("display","none");
}
});

});

You might also like