Skip to content Skip to sidebar Skip to footer

Add Validation Message In Fieldset Instead Of Js Popup

I have a php app, that has been pieced together, but I am working on an crazy validation piece, that i've got working. At the end of the validation, the following function runs an

Solution 1:

Just think about this:

function changeText(text)
{
elem = document.getElementById('error_message');
elem.innerHTML = text;
}

And you have in your html page this:

 <div id='error_message'>I'm a error message</div>      
 <button onclick="changeText('error1');">error1</button>
 <button onclick="changeText('error2');">error2</button>

With something like this you should do the trick.

Saludos.


Solution 2:

Ok, I think you can do this (if I understood your question).

function showReqFlds(emptyFlds) {
    for (var i = 0; i < emptyFlds.length; i++) {
       var holdErrMsgs = emptyFlds[i]+' is required.' + "\n";
    }
    //This is where you change
    header("location:yourpageurl.php?errorMsg=".holdErrMsgs);
} 

Then, in yourpageurl.php, in the place that you want the message, you can do something like this:

if(isset($_GET['errorMsg']))
   echo $_GET['errorMsg'];

I hope it helps you!

Best.


Post a Comment for "Add Validation Message In Fieldset Instead Of Js Popup"