Question:

Javascript verification of a field?

by  |  earlier

0 LIKES UnLike

I need ascript to check if a text box is blank or not after someone moves on to the next box. So after they set focus on it, and then remove focus of that text box, javascript will kick in and check if that box they just left focus of has a value or not, and if not prompt them to put in a value

 Tags:

   Report

1 ANSWERS


  1. I'm not exactly certain if this is what you need, but here's my best shot:

    <script type="text/javascript">

    <!--

    function checkField(txtBox) {

    if (txtBox.value=="") {

    var emptyField = prompt("Please fill in this blank");

    txtBox.value=emptyField;

    }

    }

    -->

    </script>

    <input type="text" id="text1" onBlur="checkField(this)"/>

    <input type="text" id="text1" onBlur="checkField(this)"/>

    You said prompt, right? If you just mean to pop an alert box you could just use the alert() function instead.

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.