mmorse Posted May 27, 2015 Share Posted May 27, 2015 Hello - Is there a form validation rule within fusion pro, that will only allow numbers as the input to the field once imported to the Marcom template generator? If not, is there anyone who has had tackle this challenge? I've searched extensively and attempted my writing my own rule with no luck. Here's what I've got, and I've tried various variations of this. var num = Field("zip"); var x = num.CharCode; if (num == "" || x < 48 || x > 57) { return false; }else{ return num; } Thanks! Quote Link to comment Share on other sites More sharing options...
ThomasLewis Posted May 27, 2015 Share Posted May 27, 2015 See if this works for you: function zip_validator(zip) { if ((/^([0-9]){5}(([ ]|[-])?([0-9]){4})?$/).test(zip)) return zip; else return "invalid"; } return zip_validator(Field("zip")); Quote Link to comment Share on other sites More sharing options...
mmorse Posted May 28, 2015 Author Share Posted May 28, 2015 Thank you, That worked exactly as I was hoping! A related question.... do you know if there is a way to limit the characters on the actual input field to numbers or create an error related to that field before the template is actually rendered? Thank you again! Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted May 28, 2015 Share Posted May 28, 2015 A related question.... do you know if there is a way to limit the characters on the actual input field to numbers or create an error related to that field before the template is actually rendered? That would be a question for the MarcomCentral forum. Some other systems, such as DSF, can use the field subtype, range, and data pattern defined in the HTML Form Definition (Web Collect) dialog for validation, but MarcomCentral doesn't use that, as far as I know. Quote Link to comment 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.
Note: Your post will require moderator approval before it will be visible.