Jump to content

Need to create error message when user enters an underscore


Recommended Posts



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!

Link to comment
Share on other sites

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)

	//This strips out the underscore after they type it in
	this.value = this.value.substring(0,s)

Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...