How to 'undefined' value and generate alert using jQuery

by
Category:javascript
javascript jquery
How to 'undefined' value and generate alert using jQuery

JQuery library was developed specifically to simplify and to unify certain JavaScript functionality. However if you need to check a variable against undefined value, there is no need to invent any special method, since JavaScript has a typeof operator, which is simple, fast and cross-platform.

<script type="text/javascript">
	$('#testing_sales').click(function(){
		var testing_fuel_check  = $('.testing_fuel_check').val();
		if(typeof testing_fuel_check === "undefined")
		{
			alert('Please complete Fuel Sales after than complete testing!!');
		}
		else
		{
			
		}
	});
</script>

0 Comments


Html code work in comment box


Related Post