Jump to content

Print alert if textbox has value in javascript


devidsmith

Recommended Posts

Hello Guys...

 

I have one problem in javascript guys help me i'am begginer in javascript and jquery

 

 

if user has enter value in textbox then he can't move on another screen before save the value of textbox

 

if user click on Add or Edit Button the alert box  print message 'Save the Value' it's ok .

 

but when i click on Save button, i don't want  alert box to save the textbox value

 

 

 

 

 

<script type="text/javascript">
$(document.body).click(function(){
 return check();
});
</script>

 

<script type="text/javascript">
function check() {
var txt = document.getElementById('txtbox').value;
if(txt !== '') {
    alert('Save the Value');
}

}
</script>

 

<input type="text" name="txtbox" id="txtbox"><br/>
<input type="submit" name="btn1" id="btn1" value="Save"><br/>
<input type="submit" name="btn2" id="btn2" value="Add"><br/>
<input type="submit" name="btn3" id="btn3" value="Edit"><br/>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.