JavaScript Tutorials
- What is Javascript?
- What is BOM?
- What is DOM?
- Variable
- check variable value is empty
- JavaScript Output
- Functions
- Javascript Events
- Input Events
- onchange Event
- Javascript Output methods
- If else statement
- Arrays
- Pattern Validation
- Form Validation
- Inner Html Form Validation
- Inline Form Validation
- Checkbox Validation
- Inline Inner Html Form Validation
- Server side php Validation
- Validate a HTML Form with PHP
- window and window location
- Get Text Value
- Get hidden field value
- JavaScript & PHP
- Date Format
- get php value in javascript
- Redirect page & Autoredirect page
- Auto Refresh page & Div
- How to get select text value from Dropdown box
- How to clear browser history in javascript
- Checkbox Problems
- Select option problems
- Popup Contact Form
- Sidebar Contact Form
- How to use a multistep Form or Form wizard
- Auto Calculate Price
- print Application Form
- Auto Calculate GST in Javascript by select price
- Calculate GST by input value in text box Jquery
- Calculate Discount
- onClick Checkbox
- autofil form data click on checkbox
- Show subcategory list
- Show city list as per state
- Show district list as per country and state
- Show good morning good night wish
- image upload with preview image
- Print Div Content
- Show modal popup on page load
- filter table data usign javascript.
- Character Limit Validation.
- Validate File 5MB Upload
- Validate Special character
- More File Upload
- Call JavaScript Function After Page Load
- Drop Down First option Value Disabled --- Please Select ---
- How to Disable Submit Button After Form Submission
- How to disable browser back button using Jquery?
- How to Remove selected item from second & third dropdown list?
- Interview Questions of JavaScript.
Important Link
Variable value is empty or not
How to check variale is empty or not?
File name : index.php
<select id="name" name="name" class="form-control">
<option value="">--- Select ---</option>
<option value="1">Habib</option>
<option value="2">Kalam</option>
<option value="3">Sara</option>
<option value="4">Arham</option>
<option value="5">Mahtab</option>
<option value="6">Sana</option>
</select>
<button type="button" class="btn btn-primary" name="add_name" id="add_name">Add</button>
<script type="text/javascript">
$(document).ready(function(){
$("#add_name").click(function() {
var id = $('#name').val();
//var id = $('#name option:selected');
var id_length = id.length;
if((id == '' || id == null) || (id == 'undefined' || id_length == 0))
{
swal("error!", "Please select Name", "error");
}
if(id)
{
$.ajax({
url:"",
method:"POST",
data:{id:id},
success:function(data){
//window.location.href = "mypage.php?id="+id;
swal("success!", "Standards successfully added", "success");
$("#name").val('');
}
});
}
});
});
</script>
File name : index.php
<script>
var firstName;
var lastName = null;
// Try to get non existing DOM element
var comment = document.getElementById('comment');
console.log(firstName); // Print: undefined
console.log(lastName); // Print: null
console.log(comment); // Print: null
console.log(typeof firstName); // Print: undefined
console.log(typeof lastName); // Print: object
console.log(typeof comment); // Print: object
console.log(null == undefined) // Print: true
console.log(null === undefined) // Print: false
/* Since null == undefined is true, the following statements will catch both null and undefined */
if(firstName == null){
alert('Variable "firstName" is undefined.');
}
if(lastName == null){
alert('Variable "lastName" is null.');
}
/* Since null === undefined is false, the following statements will catch only null or undefined */
if(typeof comment === 'undefined') {
alert('Variable "comment" is undefined.');
} else if(comment === null){
alert('Variable "comment" is null.');
}
</script>
File name : index.php
<form name="frm" id="frm" method="POST" action="">
<input type="text" name="title" id="title" /><br/>
<input type="text" name="name" id="name" /><br/>
<select name="state" id="state">
<option value=""> ---select--- </option>
<option value="1"> Bihar </option>
<option value="2"> UP</option>
<option value="3"> Delhi</option>
</select>
<a href="#" class="btn btn-success" id="next" onclick=
"submit_details()" type="button" name="SubmitDocument">
Submit</a>
</form>
<script>
function submit_details() {
if ($('#title').val() == "" || $('#title').val() == null)
{
$("#title").focus();
alert("Please Enter Title ");
return false;
}
else if ($('#name').val() == "" || $('#name').val() == null)
{
$("#name").focus();
alert("Please Enter Name");
return false;
}
else if ($('#state').val() == "" || $('#state').val() == null || $('#state').val() == "undefined" || $('#state').val().length == 0)
{
$("#name").focus();
alert("Please Enter Name");
return false;
}
else {
document.frm.action="ittutorial.php"; document.basic_frm.method="post";
document.basic_frm.submit();
}
}
</script>
File name : index.php