# Javascript calling variables

**URL:** <https://forum.kirupa.com/t/javascript-calling-variables/164340>\
**Category:** web dev\
**Created:** [September 30, 2005, 10:42am UTC](https://forum.kirupa.com/t/javascript-calling-variables/164340 "2005-09-30T10:42:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![adityadubey](https://avatars.discourse-cdn.com/v4/letter/a/f17d59/32.png) [@adityadubey](https://forum.kirupa.com/u/adityadubey)\
**Post date:** [September 30, 2005, 10:42am UTC](https://forum.kirupa.com/t/javascript-calling-variables/164340/1 "2005-09-30T10:42:07Z")

</div>

how do I call a variable created within a function from inside the function?

\<script\>  
function chk()  
{  
var [color=red]expression[/color] = /^[]?nill[]?$/i;  
if(document.form2.date1.value == “”)  
{  
alert(" Please enter the date or write nill")  
document.form2.date1.focus()  
}  
else if([color=red]expression[/color] != document.form2.date1.value)  
{  
alert(“done”);  
}  
\</script\>

not working.
