Morning,
I trying to create an asp "classic" version of the follow jquery/javascript function to prevent malicious code being entered in to the database.
As the user types the product name into an input field it automatically changes the html value of the permlink P and an hidden input field. Once the user hits the submit button I would like it to validate on the server side before being entered into the database.
$(".item-name").keyup(function() {
$("p.permlink").empty().html(convertToSlug($(this).val())+".html");
$(".permlink-input").empty().val(convertToSlug($(this).val())+".html");
});
function convertToSlug(Text)
{
return Text
.toLowerCase()
.replace(/[^\w ]+/g,'')
.replace(/ +/g,'-')
;
}
The only way I would know is to use the asp replace function for every character on the keybord.
replace(strItem, "<", "")
replace(strItem, ">", "")
replace(strItem, "/", "")
replace(strItem, "\", "")
... etc etc
Regards Shane