kkeiz Posted March 16, 2012 Share Posted March 16, 2012 Hello, I need to create a rule in a FusionPro template that will create an error message (customized) when a user enters an underscore in a text form field in the store. We would like to find a way to prevent a user from typing underscores in a text field (for a URL). Or is there an alternate method? I don't want to replace the underscore with another character and just adding a note is not going to be sufficient. Thank you! Quote Link to comment Share on other sites More sharing options...
step Posted March 16, 2012 Share Posted March 16, 2012 How about something like this? var s = Field("YourFieldHere"); return (s.indexOf("_") != -1) ? "<color name=\"Red\">This form can not contain underscores</color>" : s; Quote Link to comment Share on other sites More sharing options...
ThomasLewis Posted March 16, 2012 Share Posted March 16, 2012 Assuming you are using MarcomCentral you can put this in the Note field. It will probably need some tweaking to get the desired effect. <script type="text/javascript"> //This needs to match the <input id= of the field that the url is entered in. var field_id_name = "Website"; //Put your warning message in here var alert_message = "Don't do this!"; document.getElementById(field_id_name).onkeyup = alert_box; function alert_box() { var s = this.value.indexOf("_"); if (s > -1) { alert(alert_message); //This strips out the underscore after they type it in this.value = this.value.substring(0,s) } } </script> 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.