phatgreenbuds Posted February 1, 2007 Share Posted February 1, 2007 Is there a way to set up the mask of a field for like a phone number or SSN? Quote Link to comment https://forums.phpfreaks.com/topic/36685-solved-masking-fields/ Share on other sites More sharing options...
janroald Posted February 1, 2007 Share Posted February 1, 2007 Yep, you can use javascript and check for number of characters inputed every time the field changes or a key is pushed, and then add space or '-' or ':' as the next delimiter in the field. With a little hassle you can also have a default '__ __ __ __' or something in your field, and update how it looks after each time they enter something. But, no, there is no easy or built-in way to do it. Quote Link to comment https://forums.phpfreaks.com/topic/36685-solved-masking-fields/#findComment-175056 Share on other sites More sharing options...
phatgreenbuds Posted February 1, 2007 Author Share Posted February 1, 2007 ughhh...I'm just learning PHP and now I have to start thinking Javascript? I am never gonna get any sleep... Quote Link to comment https://forums.phpfreaks.com/topic/36685-solved-masking-fields/#findComment-175059 Share on other sites More sharing options...
Daniel0 Posted February 1, 2007 Share Posted February 1, 2007 Just use the password field. It masks it with asterisks. Quote Link to comment https://forums.phpfreaks.com/topic/36685-solved-masking-fields/#findComment-175061 Share on other sites More sharing options...
janroald Posted February 1, 2007 Share Posted February 1, 2007 Again, Daniel, you should read the posts :-P Think he's looking for another form of masking than you think of. Quote Link to comment https://forums.phpfreaks.com/topic/36685-solved-masking-fields/#findComment-175075 Share on other sites More sharing options...
corbin Posted February 1, 2007 Share Posted February 1, 2007 I've always used the password type to mask fields, since I do not think writing a custom way would be worth the time/effort at all. Maybe he means something else by masking, but if he means hiding the content by replacing the characters with something else that would mean nothing to someone that didn't type it, then asterisks via the password fieldtype are perfect. Also, JS is not enabled by some (very few) users so he could still use the password field type and then use your method so it wouldn't use asterisks if the user has JS, but if they didn't it would, thus still hiding the content. Or I could be entirely wrong and he is trying to make a field that is default "---------" and then you enter 1 and it becomes "1--------". Then another number: "14-------" so on... If that's the desired effect then that could easily be accomplished by javascript, but remember to set the value via JS also, so that a user with out JS will not have to manually delete what is in there... That oddly confuses some people... lol Quote Link to comment https://forums.phpfreaks.com/topic/36685-solved-masking-fields/#findComment-175077 Share on other sites More sharing options...
Daniel0 Posted February 1, 2007 Share Posted February 1, 2007 Again, Daniel, you should read the posts :-P Think he's looking for another form of masking than you think of. I did. To mask means to disguise or conceal; hide; dissemble: to mask one's intentions. I think Spry is able to do what I think s/he requests. Quote Link to comment https://forums.phpfreaks.com/topic/36685-solved-masking-fields/#findComment-175078 Share on other sites More sharing options...
phatgreenbuds Posted February 2, 2007 Author Share Posted February 2, 2007 oooook. To be clear I am not looking to hide the input like you would do for a password. By masking I mean to format, to make the input appear in a specific way. Like a phone number to look like the standard (555)555-5555 or a SSN to appear as XXX-XX-XXXX. Whatever term you use for this is what I am trying to get direction on. Sorry for the confusion. Quote Link to comment https://forums.phpfreaks.com/topic/36685-solved-masking-fields/#findComment-175139 Share on other sites More sharing options...
corbin Posted February 2, 2007 Share Posted February 2, 2007 I would just use different input boxes, or if I was trying to avoid that I would use JavaScript... Quote Link to comment https://forums.phpfreaks.com/topic/36685-solved-masking-fields/#findComment-175140 Share on other sites More sharing options...
phatgreenbuds Posted February 2, 2007 Author Share Posted February 2, 2007 well I can live without it for now. Next off-season I will pick up Javascript and start learning that. Quote Link to comment https://forums.phpfreaks.com/topic/36685-solved-masking-fields/#findComment-175143 Share on other sites More sharing options...
Sir William Posted February 2, 2007 Share Posted February 2, 2007 For phone numbers, I use three boxes. Then I use JS to auto jump to the next box as the number is filled out. This way, if they don't have JS, they can still use it the old fashioned way. Then I take the three fields, put a dash between them and store the properly formatted number in the DB. Quote Link to comment https://forums.phpfreaks.com/topic/36685-solved-masking-fields/#findComment-175241 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.