www.webdeveloper.com
Results 1 to 2 of 2

Thread: Calculator "-" problem

  1. #1
    Join Date
    Jul 2014
    Posts
    2

    Calculator "-" problem

    Hello , im newbie and im building a calculator here http://jsfiddle.net/7D9gR/7/ , but i want to make a thing , that you can type "-" only twice a row and only once in a row when "-" is the only value , i tried to do it liek this
    Code:
    function zakaz(cislica)
    {
        if(
            x.value.lastIndexOf("--")!=x.value.length-2
        )
        {x.value+=cislica}}
    which works , but with this script you cant type "-" if its going to be "2nd value"

    i would be very happy if you could help or / give me some hints , thanks for answers and have a nice day

  2. #2
    Join Date
    Jan 2005
    Posts
    372
    I don't quite follow what you mean, but I suspect the solution will probably be to do pattern matching with a Regex or two.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles