Forum : alert
Brief description  about Online courses   join in Online courses
View papaiah  ikkurthi 's Profile

alert

HI SIR HOW ARE YOU,
HOW TO GIVE ALERT NAME :TEXT BOX.... SUPPOSE IF I ENTER NUMARIC INSTEAD OF NAME I WANT GIVE ALERT TO USER THAT "PLEASE ENTER STRING(NAME)".... I AM ABLE TO GIVE ALERT TO (ENTER MARK:TEXT BOX) LIKE IF I ENTER NAME INSTEAD MARK
else if(!Number(C))
{
alert("plese enter numaric")
document.form1.num1.focus()
document.form1.num1.value=""
}
BUT NOT NAME TEXT BOX...... PLEASE HELP ME
Asked by papaiah ikkurthi | Jan 22, 2011 |  Reply now
Replies (1)
View teacher siliconindia 's Profile
Hi Papaiah,

For alphabet check, u can use regular expressions in javascript,
like below one,

function isAlpha(xStr){
var regEx = /^[a-zA-Z\s]+$/;
return xStr.match(regEx);
}

'\s' - matches whitespaces.

just go through the below chart,

Character Escapes
\f, \r, \n, \t, \v, \0, [\b], \s, \S, \w, \W, \d, \D, \b, \B, \cX, \xhh, \uhhhh \f matches form-feed.
\r matches carriage return.
\n matches linefeed.
\t matches horizontal tab.
\v matches vertical tab.
\0 matches NUL character.
[\b] matches backspace.
\s matches whitespace (short for [\f\n\r\t\v\u00A0\u2028\u2029]).
\S matches anything but a whitespace (short for [^\f\n\r\t\v\u00A0\u2028\u2029]).
\w matches any alphanumerical character (word characters) including underscore (short for [a-zA-Z0-9_]).
\W matches any non-word characters (short for [^a-zA-Z0-9_]).
\d matches any digit (short for [0-9]).
\D matches any non-digit (short for [^0-9]).
\b matches a word boundary (the position between a word and a space).
\B matches a non-word boundary (short for [^\b]).
\cX matches a control character. E.g: \cm matches control-M.
\xhh matches the character with two characters of hexadecimal code hh.
\uhhhh matches the Unicode character with four characters of hexadecimal code hhhh.
Jan 31, 2011