![]() |
| |||||||
![]() | « Previous Thread | Next Thread » |
| | LinkBack | Thread Tools | Display Modes |
| |||
| hi, I have a textbox and i want to see the user has a value entered in it If he doesnt enter a number value then fire a alert so right now I am checking that he doesnt press the space bar and have a empty space here is my code. But its not working Code:
if(trim(document.frm1.txtnumber.value)
{
alert("enter a value");
}
function Trim(s)
{
// Remove leading spaces and carriage returns
while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r'))
{ s = s.substring(1,s.length); }
// Remove trailing spaces and carriage returns
while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r'))
{ s = s.substring(0,s.length-1); }
return s;
}
|
| Sponsored Links |
| ||||
| Try this:- Code: function check_no(the_id){
var patt1 = New RegExp("^[0-9]{1,9}$");
var the_value = document.getElementById(the_id).value;
alert(patt1.test(the_value));
}
To call it have something like:- Code: <input id="no_only" type="text" size="20" />
<input id="button1" value="Click" type="button" onclick="check_no('no_only');" />
|
| |||
| hi, that works out Can you guys tell me whats wrong with this code I have a textbox if he value is blank or no value or if its $0 then i want to fire the alert I have this code Code:
var getfinallingtotal=document.frm1.total.value;
If(getfinallingtotal=="" || getfinallingtotal=="$0")
{
alert("enter something");
}
idea |
| ||||
| Try using document.getElementById instead, assuming you have given the textbox an id of total. Also try changing the double quotes to single. Code:
var getfinallingtotal=document.getElementById('total').value;
If(getfinallingtotal==''||getfinallingtotal=='$0')
{
alert('enter something');
}
|
| ||||
| What do you mean "it doesn't work"? Do you get any errors? What happens? I just tried this:- Code: function check_box(){
var getfinallingtotal = document.getElementById('total').value;
if(getfinallingtotal==''||getfinallingtotal=='$0')
{
alert('enter something');
}
}
<input id="total" type="text" size="10" />
<input id="button1" type="button" value="Check" onclick="check_box();" />
|
![]() |
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| checkbox validation | todd2006 | JavaScript Programming | 3 | June 18th, 2008 07:22 PM |
| Textbox or List help | Rebelle | JavaScript Programming | 9 | April 21st, 2008 10:00 AM |
| Programmatically Add Item to Validation Summary | jmurrayhead | .Net | 0 | March 20th, 2008 09:41 AM |
| Sponsored Links |
| ASP.NET Resource Index a directory of ASP.NET tutorials, applications, scripts, assemblies and articles for the novice to professional developer. Free Web Directory Including Chats and Forums Resources, Offer automatic, instant and free directory submissions. | URLZ Web Directory URLZ Web Directory Free Web Directory - Add Your Link The Little Web Directory | Free Web Directory Pegasus free web directory is a free directory organised by categories. Web Directory & SEO Services dirroot web directory |