Possible Duplicate:
How do you pass a variable to a Regular Expression JavaScript?
I need help to resolve the issue because the code fails due to numLength[0]:
<html>
<body>
<script type="text/javascript">
function xyz(){
var predefLength = "5,5";
var number = "20";
var numLength = predefLength.split(",");
var result = /^[-+]?\d{0,numLength[0]}(\.\d{0,numLength[1]})?$/.test(number);
document.write(result);
}
</script>
</body>
</html>
Any help will appreciated.