Código PHP:
function comprobar2(){
if (( document.getElementById("name").value.length==0) || (document.getElementById("surname").value.length==0 ) ||
(document.getElementById("correo2").value.length==0 ) || (document.getElementById("contraseña").value.length==0) || (document.getElementById("inputString").value.length==0)){
javascript:cartelmax.className='max'
document.getElementById("name").focus()
return 0;
}else{
document.perfil.submit();
}
}
<form action="creausuarios.php" method="post" id="perfil" name="perfil">
<div class="divinput" >
<input type="text" maxlength="20" id="name" onkeypress="valida2(event)" name="name" placeholder="Nombre" class="input" /><br/>
<input type="text" maxlength="20" id="surname" onkeypress="valida2(event)" name="surname" placeholder="Apellidos" class="input" /><br/>
<input type="text" maxlength="60" placeholder="Correo electrónico" onkeypress="valida2(event)" id="correo2" name="correo2" class="input" /><br/>
<input type="password" maxlength="30" placeholder="Contraseña" onkeypress="valida2(event)" class="input" id="contraseña" name="contraseña" /><br/>
</div>
<div>
<input type="text" class="selectcolegio" placeholder="Nombre de la escuela" name="selectcolegio" size="30" value="" id="inputString2" onkeyup="lookup2(this.value);" />
</div>
<div id="suggestions2"></div>
<input type="button" id="reg" name="reg" value="Registrarse" class="botonsubmit" onclick="comprobar2()" />
</form>