I have a dynamic page set up where artists can create their own pages/profiles. We are trying to make it so artists can’t create the same name as this would result 2 people using one URL (url is based on artist name) and someone would lose control of their profile along the way. To do this we set up a query to check our database to see if there are any artist names that match, if so it will disable the button and give them an error msg. The issue is that this is case sensitive so this allows artists to create the same name (if using caps etc…) is there a way to make this not case sensitive so that it will catch all of the duplicates. I will paste the code below to reference.
any help would be much appreciated! thanks in advance
function doChecks ( ){
wixData . query ( "ArtistsProfileData" )
. eq ( "artistName" , $w ( "#iptArtistName" ). value )
. limit ( 1 )
. find ()
. then (( results ) => {
**if** ( results . items . length > 0 ){
$w ( "#txtMessage" ). text = "This user name is already taken, please choose another." ; $w ( "#txtMessage" ). show ();
$w ( "#btnActivate" ). disable ();
} **else if** ( $w ( "#iptArtistName" ). value . length < 2 || $w ( "#iptArtistName" ). value . length > 18 ){
$w ( "#txtMessage" ). text = "Please enter a user name between 2 and 18 characters." ; $w ( "#txtMessage" ). show ();
$w ( "#btnActivate" ). disable ();
} **else** {
setTimeout ( '' , 5000 );
$w ( "#btnActivate" ). enable ();
$w ( "#txtMessage" ). hide ();
}
})
}
export function iptArtistName_keyPress ( event ) {
setTimeout ( doChecks , 50 );
}