Help for repeating dots(solved)

Help for repeating dots(solved)
0

#1

How I prevent repeating dots here?

//getting number with dot
$("#numbers #dot").click(function(){

dot= this.text;
if(number===""){
number=“0”+dot;
}else{
number= number+dot;
}
resultDiv.val(number);

});


#2

You could search number for occurrences of “.” and only add the dot if it isn’t found. indexOf would work (returns -1 if not found), or you could evaluate via regular expression.


#3

thank you. I solved it.