0

I am trying to setup field masks for my HTML form, and am going with IMask

Step one was quite simple - upload the Java scripts to my server and then add

<script type="text/javascript" src="js/mootools.js"></script>  
    <script type="text/javascript" src="js/imask.js"></script>

to my forms head. The next step however I am completely lost on what to do with.

But here is where I need your help please.

Initialize the iMask class:

view plainprint?
new iMask({  
    onFocus: function(obj) {  
        obj.setStyles({"background-color":"#ff8", border:"1px solid #880"});  
    },  

    onBlur: function(obj) {  
        obj.setStyles({"background-color":"#fff", border:"1px solid #ccc"});  
    },  

    onValid: function(event, obj) {  
        obj.setStyles({"background-color":"#8f8", border:"1px solid #080"});  
    },  

    onInvalid: function(event, obj) {  
        if(!event.shift) {  
            obj.setStyles({"background-color":"#f88", border:"1px solid #800"});  
        }  
    }  
});  

Where to place this code?

zvisofer
  • 1,346
  • 18
  • 41
JefeTheTechy
  • 65
  • 1
  • 1
  • 7

1 Answers1

0

I believe that code is to go at the bottom of the page in between <script></script> tags.

colinplusplus
  • 303
  • 1
  • 4
  • That did get the masking to work thank you. However the form is still not mandating the input. For instance now on the Social Security field, I have a placeholder of 000-00-0000. However the from still accepts ANY input for that field and is not requiring the input be in the format 000-00-0000. In fact I notice the user can actually delete out the mask and then enter anything they want- completely not the point of trying to implement the field masking. – JefeTheTechy Feb 08 '14 at 17:30
  • The iMask doesn't do error checking. For that you will need to add your own Javascript and php code. There are many examples of this code on the internet. Try to Google "form validation code." – colinplusplus Feb 10 '14 at 15:16