$(document).ready(function() {
	$('#butsaveNU').on('click', function() {
		$("#butsaveNU").attr("disabled", "disabled");
		var username = $('#nu_username').val();
		var password1 = $('#nu_password1').val();
		var password2 = $('#nu_password2').val();
		var userlevel = $('#nu_user_role').val();

		if(username!="" && password1!="" && password2!="" && userlevel!=""){

			if(password1!=password2) {
			alert("Passwords do not match..");
			}
			else {

			$.ajax({
				url: "addUser.php",
				type: "POST",
				data: {
					username: username,
					password: password1,
					userlevel: userlevel	
				},
				cache: false,
				success: function(dataResult){
					var dataResult = JSON.parse(dataResult);
					if(dataResult.statusCode==200){
						$("#butsaveNU").removeAttr("disabled");
						$('#fupForm').find('input:text').val('');
						$("#successNU").show();
						$('#successNU').html('User added successfully !'); 						
					}
					else if(dataResult.statusCode==201){
					   alert("Error occured !");
					}
					
				}
			});
			}
		}
		else{
			alert('Please fill all the field !!');
		}
	});
});