简体   繁体   中英

Change Element Class From Another PHP Page With JQUERY

I'm trying to add an error reporting box using Bootstrap-4.

The Alert loads with the class of 'collapse' on the registration page:

<input type="text" id="inputEmail" class="form-control" name="username" 
placeholder="Username" required minlength="4" autofocus>
            <div id=error_message class=collapse>
              <span class="alert alert-danger"> <STRONG>Error:</STRONG><? 
$_SESSION['message'] ?>
            </span>

The form handler is here with a placeholder for code, as a separate PHP file.

mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);

$num = mysqli_num_rows($result);

//Test to see if username exists
if ($num != 0 ){
$_SESSION['message']="The username is already taken";
//JQUERY HERE TO SHOW BOOTSTRAP ALERT DIV - CLASS TO 'SHOW'
}
?>

It it possible, or indeed wise to get JQuery to affect the class on another page, or am I looking at this wrong way? Apologies I'm a rank amateur and I'm very new to this.

You can achieve it with bootstrap validation with remote file. For reference go through https://formvalidation.io/guide/validators/remote/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM