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


This topic is now archived and is closed to further replies.

  • Create New...